如何从视图将多个参数传递给操作方法
中执行类似的操作
<select onchange="location = this.value;">
<option value="/product/categoryByPage/[email protected],limit=15" selected="selected">15</option>
<option value="/product/categoryByPage/[email protected],limit=30"
selected="selected">30</option>
<option value="/product/categoryByPage/[email protected],limit=50"
selected="selected">50</option>
</select>
我正在category.cshtml视图页面和控制器
[ActionName("categoryByPage")]
public ViewResult Category(Guid id, string limit)
{
Category cat = db.Categories.Find(id);
return View(cat);
}
:但它不起作用,并且控制器方法无法获取该参数...
提前致谢,
米兰
i'm doing something like this in category.cshtml view page
<select onchange="location = this.value;">
<option value="/product/categoryByPage/[email protected],limit=15" selected="selected">15</option>
<option value="/product/categoryByPage/[email protected],limit=30"
selected="selected">30</option>
<option value="/product/categoryByPage/[email protected],limit=50"
selected="selected">50</option>
</select>
and from controller :
[ActionName("categoryByPage")]
public ViewResult Category(Guid id, string limit)
{
Category cat = db.Categories.Find(id);
return View(cat);
}
but it isn't working and controller method unable to fetch that parameters ...
thanks in advance,
Milan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要按如下方式更改 url 才能使用默认路由:
请注意,id 实际上是默认路由中的最后一个参数,您需要的任何额外参数都需要以查询字符串格式提供
you need to change your url as follows to work with default routing:
Note that id is actually in the default route as the last argument, any extra parameters you need need to be provided in query string format