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