MVC3 why use html.editorfor

I look at examples of the MVC3 razor and see that html.editor is being used, and also asked a lot about this forum. Why can't I use html.textboxforand passwordfor? Thanks

+5
source share
2 answers

EditorFor has the advantage of trying to display an editor associated with a data type.

For example: if you create your own Editor Templates , they will be automatically displayed based on the property type or UIHint

A useful editor template may be one that generates a date picker when the property type is DateTime.

, "" ForFor "" , , <textarea> MultilineText

TextBoxFor PasswordFor , " ". HtmlAttributes.

+9

Ref Html.TextboxFor Html.EditorFor MVC Razor .

HtmlTextboxFor textbox (<input type="text" ...).

EditorFor , .

, DateTime , jQuery DatePicker.

- , , div, (~/Views/Shared/EditorTemplates/string.cshtml), , if hardcoded Html.TextBoxFor, .

+6

All Articles