我正在尝试在MVC 4视图上有多个提交按钮,然后根据单击的按钮选择要在控制器中执行的操作。但是,控制器无法识别单击了哪个按钮并始终显示为null。
我做错了什么?
//View
@using (Html.BeginForm())
{
<button type = "submit" name = "btn" value = "save_new" id = "SaveNew" > Save & amp; New </button>
<button type = "submit" name = "btn" value = "save_close" id = "SaveClose" > Save & amp; Close </button>
}
//Controller
public ActionResult PortalAccountMapping(PortalAccountMappingModel model, string btn)
{
if (btn == "save_new")
{
// the form was submitted using the Save&New button
}
else if (btn == "save_close")
{
// the form was submitted using the Save&Close button
}
else
{
UpdateModel(model.Grid.UpdateParams);
return Json(model.GetRows());
}
return View();
}
btn值始终为空。
答案 0 :(得分:0)
Message = Client.PostAsync(CompleteURL, Content).Result
这是我使用的