HI,
Does anyone know how can I receive the modified model value which I have bound to controls on view page. For instance I have used a text box on view, as follows-
<%=Html.TextBoxFor(model => Model.firstName, new { id = "txtFirstName"})%>
But in my post method I am not able to receive the modified value from the text box.
Any solution?
Thanks,
Kapil
You have renamed your model’s required field to txt….
The framework maps html fields by name to your class properties as there is no txtFirstName in your class it cannot automatically map them. (as the html field name and the model property name must match for binding)
if you do the following it will bind correctly
If you want to use the renamed field i.e. { id = “txtFirstName”} then you can either create a new class and bind to that as in:
and in your controller
or
You could go further and define a custom binder, to strip the txt or other prefix/s if your naming standards dictate that you have to use specific prefixes txt/cbo/chk etc.