视图中的多个模型
LoginViewModel
RegisterViewModel
.
G.
public class LoginViewModel{ public string Email { get; set; } public string Password { get; set; }}public class RegisterViewModel{ public string Name { get; set; } public string Email { get; set; } public string Password { get; set; }}
public BigViewModel{ public LoginViewModel LoginViewModel{get; set;} public RegisterViewModel RegisterViewModel {get; set;}}
BigViewModel
):
@model ViewModel.RegisterViewModel @using (Html.BeginForm("Login", "Auth", FormMethod.Post)) { @Html.TextBoxFor(model => model.Name) @Html.TextBoxFor(model => model.Email) @Html.PasswordFor(model => model.Password) } @model ViewModel.LoginViewModel @using (Html.BeginForm("Login", "Auth", FormMethod.Post)) { @Html.TextBoxFor(model => model.Email) @Html.PasswordFor(model => model.Password) }