ASP. NET MVC @Html class

Source: Internet
Author: User

The class in model

Using System.Web;
Using System.ComponentModel;

public class Guestbook
{
public int Id {get; set;}

[DisplayName ("Display name")]
public string Name {get; set;}
[DisplayName ("E-mail Address")]
public string Email {get; set;}
public string Infor {get; set;}
}

Model types are the main models (types) introduced by @model

1, @Html. Displaynamefor (model = model. Name) output "Display name" if [DisplayName ("Display name")] is not displayed, the name

2, @Html. Displayfor (modelItem1 = Item. Name) output item. The value of name

3, @Html. ActionLink ("register", "register", "Account", Routevalues:null, htmlattributes:new {id = "Registerlink"}) the output hyperlink parameter is: The name of the hyperlink, the purpose of the link Action, the controller that is connected, the attribute of the route parameter id,html, and the value,<a href= "/account/register" id= " Registerlink "> Registration </a>

4, @Html. ValidationSummary () Returns the result of the form being validated in the background, which defaults to true, and if False generates additional <div><<ul><li style= " Display:none "></li></ul></div> centralized display error

5,   @Html. labelfor (model = model. Name) output <label for= " name ">name</LABEL>

6,   @Html. editorfor (model = model. Name) output <input class= " text-box single-line " id=" name "name=" name "type=" Text "value=" "/>

7, @Html. validationmessagefor (model = model. Infor) output <span class= " field-validation-valid "data-valmsg-for=" Span class= "Html-attribute-value" >email "data-valmsg-replace=" true" ></span>8
8, @using (Html.BeginForm ("ActionName", " Controllername ", Formmethod.method)) {...} Output    <form action= "/Controller /action "method=" post ">....</form >formmethod.method default post

9,   @Html. AntiForgeryToken ()   http://www.cnblogs.com/pigjar/archive/2011/07/08/postonly.html

@Html. hiddenfor (model = model. Id) output hidden field <input .... type= "Hide" value=model.id/>

ASP. NET MVC @Html class

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.