【发布时间】:2012-10-27 18:01:29
【问题描述】:
我的搜索页面有很多参数,在这个页面中我有一些当前搜索的过滤器。
我只想更改路线中的一些值。
一个例子:
http://www.example.com/{controller}/{action}/{brand}/{model}/{color}/{price}
在我的搜索页面中,我有一个可以更改颜色和价格的表单:
HTML:
@using (Html.BeginForm("action", "controller", FormMethod.Post))
{
@Html.DropDownListFor(m => m.Color, Model.Colors)
@Html.DropDownListFor(m => m.Price, Model.Prices)
<input type="submit" value="Search" />
}
控制器:
[HttpPost]
public ActionResult Action(SearchModel search)
{
//I can get the Price and Color
string color = search.Color;
string price = search.Price;
//Now I want to get the values of brand and model
return RedirectToRoute("Action",new
{
controller = "Controller",
action = "Action",
color = color,
price = price,
brand = ????,
model = ????
});
}
我的搜索有比这更多的参数...我不想将它们放在隐藏字段中并与模型一起发送:\
谢谢
【问题讨论】:
-
您不想要什么?隐藏字段?如果这些是您的搜索参数,那么它们应该对用户可见,不是吗?或者是否存在用户输入可能会更改将发送用于搜索的参数的情况?
-
嗨!我只想在控制器中捕获品牌和型号值(在本例中)。用户输入只会改变颜色和价格值。
标签: c# asp.net-mvc routes