MVC3 Form binding duplicated across two neighbouring html forms

蓝咒 提交于 2019-12-07 18:13:28
Rodrigo Caballero

If your html elements have the same Id you might expect this kind of behaviors. I think that the easiest solution for this is to rename your login username id name into a more explicit one like LoginUserName. this way you are not mixing two different things.

Second, I suggest you (if you haven't done so) to encapsulate your login functionality into a separate form (if that applies) because you would be sending the whole page, including use cases that don't apply to a login action.

Seems like the issue with same client input names. Take a look at BindAttribute.Prefix and TemplateInfo.HtmlFieldPrefix. By using them you can generate different client ids and names for those different actions and models, and the problem will probably be solved. HtmlFieldPrefix is used for appending prefix for client generated ids, and the Bind.Prefix is used for binding back client form values generated with HtmlFieldPrefix. Both of them are set in controller action.

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