这是我暂时无法弄清楚的事情:
在我看来,我写的是这样的:
@using(Html.BeginForm("PIndex","Home")){
<select name ="particalview">
<option value="1">option 1</option>
<option value="2">option 2</option>
</select>
背后的控制器是:
[HttpPost]
public ActionResult PIndex(string i) {
if (i == "1")
ViewBag.Page = 1;
else if(i == "2")
ViewBag.Page = 2;
if(i == null)
ViewBag.Page = 3;
return View();
}
无论我选择什么,控制器都无法获得选择列表的参数,有人能告诉我我错过的地方吗?
答案 0 :(得分:1)
将PIndex中的参数更改为particalview
[HttpPost]
public ActionResult PIndex(string particalview) {
if (particalview == "1")
ViewBag.Page = 1;
else if(particalview == "2")
ViewBag.Page = 2;
if(particalview == null)
ViewBag.Page = 3;
return View();
}