@Html Helper is a simple description of the basic HTML with the corresponding @html helper, @Html basically contains the HTML of the form control and common HTML
In @html, the with for is primarily for strongly typed HTML types.
Used to describe tags in @html, define student objects for auxiliary instructions,
[HTML]View plain copy
- public class Student
- {
- <summary>
- Name
- </Summary>
- ///
- [DisplayName ("name")]
- public string Name
- {
- Get
- Set
- }
- <summary>
- Age
- </Summary>
- public int Age
- {
- Get
- Set
- }
- }
Define @model Student on the cshtml page
Label label, implemented in the Labelextensions class
1, @Html. Label ()
Returns an HTML label element and the property name of the property represented by the specified expression.
Parameter: string expression,string labelText
Expressions: An expression that represents the property to display
LabelText: Display text
Cases:
[HTML]View plain copy < param name= "allowfullscreen" value= "false" >< param name= "wmode" value= "Transparent" >
- @Html. Label ("Weight") Output:<label for="Weight">weight</label>
- Abel ("name", "name") Output:<label for="name"> Name </label>
2, @Html. Labelfor ()
Similar to @html.label (), but mainly for strongly typed
Cases:
[HTML]View plain copy
- @Html. Labelfor (model=>mode. Name) Output: <label for="Name">name</label>
- @Html. Labelfor (model=>mode. Name, "name") Output:<label for="name"> Name </label>
- If the [DisplayName ("name")] attribute (reference System.ComponentModel;) is added to the entity above, it will be displayed:
- <label for="name"> Name </label> for displaying Chinese characters is convenient
3, @Html. Labelformodel ()
Example: @Html. Labelformodel ("name") Output: <label for= "" >name</label>
The use of @html tags in ASP.