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://hzjierui.cn/article/gccepd.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款