English Phrases

http://www.ihbristol.com/english-phrases

 

Advertisements

ASP .NET MVC Model Binding

Model binder takes the values coming from an HTML page and maps them to a corresponding model.

The Model binder is capable of retrieving the data from HTML form variables, POSTed variables and files, query string parameters and the values added in the routes.

The DefaultModelBinder class magically does all the type conversion and mapping of all values to the Model properties.

The id of the HTML input fields must be same as the Property names of the Model. The mapping will be based on the Property name by default.  HTML helper methods are very helpful here because these helper methods will generate the HTML proper IDs for the Model.