I am looking at MVC3 razor examples and seeing html.editorfor being utilized and also asked about a lot on this forum. Why can’t i use html.textboxfor and passwordfor? Thanks
I am looking at MVC3 razor examples and seeing html.editorfor being utilized and also
Share
EditorFor has the advantage that it will try to render an editor associated to the data type.
For example: If you design your own Editor Templates they will automatically be rendered based upon the property’s type or UIHint
A useful editor template might be one that generates a date picker when the property’s type is a
DateTime.There are some other scenarios as well where the ‘smart’ EditorFor will generate the ‘best’ editor for the property such an example is when it renders a
<textarea>when tagging the property withMultilineTextUsing TextBoxFor and PasswordFor are perfectly fine for those cases where you don’t require ‘a special editor’. It might even simplify your life when having to set HtmlAttributes.