MVC 3 Razor Form Post w/ Multiple Strongly Typed Partial Views Not Binding

巧了我就是萌 提交于 2019-12-03 07:25:25

This is because your Partial views are strongly typed. Remove the @model declaration in your Partials and access the Model properties like this

@Html.Partial("_LoginAccount")

and then in your partial

<div>
     @Html.TextBoxFor(mod => mod.UserLogin.LoginId)
     @Html.PasswordFor(mod => mod.UserLogin.Password)
</div>

All partials views should be strongly typed with the same view model (AccountSetup in your case) :

@model Models.Account.AccountSetup

@Html.TextBoxFor(mod => mod.UserLogin.LoginId)
@Html.PasswordFor(mod => mod.UserLogin.Password)

Then:

@Html.Partial("_LoginAccount", Model)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!