浏览动作:
public ActionResult Browse(int? Category, string sortOrder, string currentFilter, string searchString, int? page)
我可以使用操作链接发送类别ID
@Html.ActionLink("Name", "Browse", new { sortOrder = ViewBag.NameSortParm, currentFilter=ViewBag.CurrentFilter, Category=ViewBag.CategoryId })
如何将类别ID从表单传递给控制器?
<div id="search">
@using (Html.BeginForm("Browse", "Home", FormMethod.Get))
{
@Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
<input type="submit" value="Search" />
}
</div>
答案 0 :(得分:0)
您可以通过隐藏的输入发送它:
@using (Html.BeginForm("Browse", "Home", FormMethod.Get))
{
@Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
@Html.Hidden("Category",ViewBag.CategoryId)
<input type="submit" value="Search" />
}