Editor templates are used to automatically generate form input elements based on the datatype of an object's properties. ASP.NET MVC contains a number of standard editor templates but developers are also able to create their own. Editor templates are similar to partial views, but where partial views are rendered by name, editor templates are rendered by type.
When using Visual Studio's default scaffolding functionality to create an edit view for your model, it generates text input elements using the EditorFor
HTML helper as follows:
@Html.EditorFor(model => model.CategoryName)
The EditorFor
helper renders HTML for the model
property based on its datatype. In the case of a string value, the resulting markup will look similar to the following:
<input type="text" name="CategoryName" id="CategoryName" data-val-required="The Category Name field is required." data-val="true" class="text-box single-line">