ASP.NetMVC实现一个表单多个submit

1. 用Html.BeginForm(ActionName,ControllerName,Post)来实现controller-action的路由,
2. Form里的每个input的name值统一,比如都命名为commandName, 每个input的value设为不同值。
3. 更改Action处理方法的参数, 添加一个参数为commandName,则commandName的值为input设置的value。

例:

@using (Html.BeginForm("SaveRisDBConfig", "Home", FormMethod.Post)) {   
@Html.LabelFor(model => model.DBHost)
@Html.EditorFor(model => model.DBHost) @Html.ValidationMessageFor(model => model.DBHost)
}


 [HttpPost] public ActionResult SaveRisDBConfig(string commandName) 
 { 
      switch (commandName) 
      {           case "保存": 
                .... 
           case "连接测试": 
                ... 
           default: 
                break;      } 
 } 

文章标题:ASP.NetMVC实现一个表单多个submit
路径分享:http://csdahua.cn/article/gccepd.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流