@Html. Editorfor ()
returns an INPUT element that corresponds to each property in an object represented by an expression, mainly for strongly typed, which is generally used more often
A, @Html. Editorfor (Mode=>mode. Name)
If the returned view assigns a value to the student entity, the output output <input class= "Text-box single-line" id= "name" name= "name" type= "text" value= "Default value" /> Otherwise value is "";
B, @Html. Editorfor (Mode=>mode. Name, "templatename")
The second parameter is the template name, which defines the template:
first create a folder in directory view/shared/editortemplates/templatename.cshtml that is: view/shared/editortemplates/templatename.cshtml
Note: It is important to use EditorTemplates as a folder
The templatename.cshtml code is: @Html. DropDownList ("", New SelectList (New []{"1", "2", "3"}) represents a drop-down list with a value of
you can then call @html.editorfor (Mode=>mode. Name, "templatename"), is displayed as a drop-down list, which appears as a text box if a text box is set in the template.
also, the name attribute in the entity student can be added with the [UIHint ("templatename")] attribute if you add this, you can not display the specified template name at the time of the call
with @html.editorfor (Mode=>mode. Name) can be displayed as a drop-down box, and all of this field will become a drop-down list
equivalent to the input control in HTML
@Html. Editorfor (Model=>model. Age)
The page is displayed as: <input id= "Age" name= "age" type= "text" value= ""/>
3, @Html. Editorformodel ()
If you use the default value without any parameters, the loop displays all the information in the model, but it needs to be placed in a loop
such as: <input class= "Text-box single-line" id= "name" name= "name" type= "text" value= ""/>
<input class= "Text-box single-line" id= "Age" name= "age" type= "text" value= ""/>
Actually about B I found @Html. Editorfor (Mode=>mode. Name, "TemplateName") written
@Html. Editorfor (Mode=>mode. Name, @Html. DropDownList ("", New SelectList (New []{"1", "2", "3"}) can also be generated after Html or input is not quite clear.