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.

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s