标签:null inpu pre initial data net multi 通过 info
上一遍说道用Tuple实现Asp.net Mvc action返回多个模型实体给view,此篇发过来,实现view表单提交多个实体模型到action。
1、view代码:
@{ Layout = null; } @model Tuple<Model.UserInfo, Model.UserSlave> <!DOCTYPE html> <html> <head> <title></title> <meta name=‘viewport‘ content=‘width=device-width,initial-scale=1.0‘> </head> <body> <div > @using (Html.BeginForm("Add", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })) { <table> <tr> <td>姓名</td> <td> @Html.TextBoxFor(model => model.Item1.Name, new { placeholder = "姓名", maxlength = "20" }) </td> </tr> <tr> <td>邮箱</td> <td> @Html.TextBoxFor(model => model.Item2.Email, new { placeholder = "邮箱", maxlength = "30" }) </td> </tr> </table> <input type="submit" name="submit" value=‘提交‘> } </div> </body> </html>
2、action代码:
public ActionResult Add() { var name = Request.Form["Item1.Name"];//姓名 var email = Request.Form["Item1.Email"];//邮箱 }
通过Request.Form["Item1.Name"];获取对应实体的传过来的参数。
标签:null inpu pre initial data net multi 通过 info
原文地址:http://www.cnblogs.com/qk2014/p/7260278.html