Templated HTML Helpers

These helpers figure out what HTML elements are required to render based on properties of your model class. This is a very flexible approach for displaying data to the user, although it requires some initial care and attention to set up. To setup proper HTML element with Templated HTML Helper, make use of DataType attribute of DataAnnitation class.
For example, when you use DataType as Password, A templated helper automatically render Password type HTML input element.

Templated Helper Example
Display Renders a read-only view of the specified model property and selects an appropriate HTML element based on property’s data type and metadata. Html.Display(“Name”)
DisplayFor Strongly typed version of the previous helper Html.DisplayFor(m => m. Name)
Editor Renders an editor for the specified model property and selects an appropriate HTML element based on property’s data type and metadata. Html.Editor(“Name”)
EditorFor Strongly typed version of the previous helper Html.EditorFor(m => m. Name)

Tagged , . Bookmark the permalink.

Leave a Reply