The last time I said, implementing the ASP. NET MVC action returns multiple model entities to view, which is sent to implement the view form to submit multiple entity models to the action.
1. View Code:
@{Layout=NULL;} @model Tuple<model.userinfo, model.userslave><! DOCTYPE html>'Viewport'Content='width=device-width,initial-scale=1.0'>@using (Html.BeginForm ("ADD","Home", FormMethod.Post,New{enctype ="Multipart/form-data" })) { <table> <tr> <td> name </td> <td>@Html. Textboxfor (Model= Model. Item1.name,New{placeholder ="name", maxlength =" -" }) </td> </tr> <tr> <td> Email </td> <td>@Html. Textboxfor (Model= Model. Item2.email,New{placeholder ="Email", maxlength =" -" }) </td> </tr> </table> <input type="Submit"Name="Submit"Value='Submit'> } </div></body>2. Action code:
Public actionresult Add () { var name = request.form["item1.name"]; // name var email = request.form["item1.email"]; // Mailbox }
by request.form["Item1.name"]; Gets the passed-in parameters of the corresponding entity.
ASP. NET MVC Post form submits multiple entity models