The use of @html tags in ASP.

Source: Internet
Author: User

@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
  1. public class Student
  2. {
  3. <summary>
  4. Name
  5. </Summary>
  6. ///
  7. [DisplayName ("name")]
  8. public string Name
  9. {
  10. Get
  11. Set
  12. }
  13. <summary>
  14. Age
  15. </Summary>
  16. public int Age
  17. {
  18. Get
  19. Set
  20. }
  21. }


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" >
    1. @Html. Label ("Weight") Output:<label for="Weight">weight</label>
    2. 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
  1. @Html. Labelfor (model=>mode. Name) Output: <label for="Name">name</label>
  2. @Html. Labelfor (model=>mode. Name, "name") Output:<label for="name"> Name </label>
  3. If the [DisplayName ("name")] attribute (reference System.ComponentModel;) is added to the entity above, it will be displayed:
  4. <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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.