Model Binding HTML control to Model Property with a different name
I have an HTML input control on one of my views that is called for example 'BodyInput'. When I post the form I am checking if the ModelState is valid or not. The other few input controls on my view validate fine, as the name of the properties in my model are exactly the same as the na开发者_运维问答me of the HTML controls, but the name of my property for the 'BodyInput' control to map to, is 'Body'.
Lets say I can't change the name of either the property in my model, or the Html input control - can I use data annotations (or anything) to map/associate the property and control for model binding?
Found a solution in another question as pointed out by user ipr101.
Bind formValue to property of different name, ASP.NET MVC
精彩评论