Changing Posted Form Values in ASP.Net MVC 3

A quick note to explain the way ASP.MVC apparently applies form values using the html helper methods (EditorFor, TextBoxFor etc)

On a GET, the form values are extracted from the ViewModel as you would expect, so if you have some pre-populated values in the model then those values will be shown as the field values.

On a POST however any modifications to the model state in the controller are ignored by the helper methods – the originally posted values are used in preference.

If you need to display a field that is likely to be modified before re-presentation to the user, you need to implement the field without the aid of the helpers.

This entry was posted in ASP.Net MVC and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s