我使用两个提交按钮。 (asp.net MVC3 aplicattion)多次提交按钮(asp.net mvc3)
如果这样就把MultiButtonAttribute类?在控制器?
也许是最简单的方法来做到这一点。
我使用两个提交按钮。 (asp.net MVC3 aplicattion)多次提交按钮(asp.net mvc3)
如果这样就把MultiButtonAttribute类?在控制器?
也许是最简单的方法来做到这一点。
,你可以在任何地方应用程序添加它包括控制器文件夹
**//model**
public class input_element
{
public string Btn { get; set; }
}
**//views**
@using (Html.BeginForm())
{
<button type="submit" name="btn" value="verify">
Verify data</button>
<button type="submit" name="btn" value="save">
Save data</button>
<button type="submit" name="btn" value="redirect">
Redirect</button>
}
**//controller**
public ActionResult About()
{
ViewBag.Message = "Your app description page.";
return View();
}
[HttpPost]
public ActionResult About(input_element model)
{
if (model.Btn == "verify")
{
// the Verify button was clicked
}
else if (model.Btn == "save")
{
// the Save button was clicked
}
else if (model.Btn == "redirect")
{
// the Redirect button was clicked
}
return View();
}
您不回答OP在此处询问的问题。 –
你可以把类,只要在任何地方,因为在使用控制器的参考。 –
根据你的需要,你可能不需要使用它。如果第二个按钮不需要表单中的变量(例如,它是“创建新行”按钮),则只能为第二个按钮创建第二个表单。这使得它更简单。 –
好的,如果我使用按钮,如何加入这个Redicttoaction?我的意思是,如果我按下按钮,我会转到另一边? – user1031034