EditorForModel HTML Helper in MVC3 Razor

  1. This HTML Helper  generates HTML Labels and editor elements for the properties  in the model object.
  2. We do not need to pass the model to the helper as a parameter  because it is read directly directly from the view by the helper.

Example 1 :

Syntax :


    @Html.EditorForModel()


Model :



This is the model class for which we are using EditorForModel helper. In the above syntax we are not specifying the name of the model or the tamplate name. This overload reads the template name from the view itself.

View Reference :

We can also specify the template name as shown below.


    @Html.EditorForModel("Register")

UI :



The html helper renders the editor for all the properties. 

0 comments:

Post a Comment