1

我认为有一个表格:

@using(Html.BeginForm("Details", "Category", FormMethod.Get))
{
    <input type="text" name="param1" />
    <input type="submit" value="OK" />
}

此表单在带有参数的页面上,~/category/details?view=list我从路由查询字符串中获取视图参数的值,并希望将其传递给我的表单生成的请求。我想要请求查询字符串?param1=inputedText&view=list而不是?param1=inputedText. 如果不向我的表单添加隐藏输入并为其设置view值,我该如何做到这一点?

4

1 回答 1

0
public ActionResult Details(string view )
{
    ViewBag.view = view ;
       return View();
}

public ActionResult Details(string view ,string param1)
{
    ViewBag.view = view ;
       return View();
}

这个方法可以帮助你

@using(Html.BeginForm("Details", "Category", FormMethod.Get))
{ 
    <input type="Hidden" name="view" value=ViewBag.view >
    <input type="text" name="param1" />
    <input type="submit" value="OK" />
}
于 2012-09-05T07:18:12.887 回答