Without its own control in the ASP. NET, the page display is completely back to the age of the HTML code. Fortunately, there are also two helper classes in the ASP. HtmlHelper and Urlhelper. In addition, some help classes are extended in the Mvccontrib extension project, so that we can use these helper classes not only to write the pages that need to be displayed, but also to use the full HTML.
1.ActionLink
< div > @Html. ActionLink ("This is a test", "other", "Home"); The wording with QueryString @Html. ActionLink ("This is a test", "other", "Home", new {page = 1}); @Html. ActionLink ("This is a test", "other", "Home", new {page = 1}, NULL); QueryString and Html properties exist at the same time @Html. ActionLink ("This is a test", "other", "Home", new {page = 1}, new {id = "Link1"}) @ Html.ActionLink ("This is a test", "other", new {page = 1}, new {id = "Link1"}) actual use (Popup new window) @Html. ActionLink ("This is a Test, "Other", "Home", new {page = 1}, new {target = "_blank"}); </ DIV>
<div> <a href= "/home/other" > This is a test </a>; With querystring <a href= "/home/other? Length=4 "page=" 1 "> This is a test </a>; <a href= "/home/other?page=1" > This is a test </a>; QueryString and HTML properties exist <a href= "/home/other?page=1" id= "Link1" > This is a test </a> <a href= "/home /other?page=1 "id=" Link1 "> This is a test </a> practical use (Popup new window) <a href="/home/other?page=1 "target=" _blank "> This is a test </a>; </div>
2.RouteLink same as the ActionLink function .
<%=Html.routelink ("about the", " About", New { })%>with QueryString<%=Html.routelink ("about the", " About", New{page= 1 })%> <%=Html.routelink ("about the", " About", New{page= 1 }, New{ID= "Link1" })%>Build Result:<ahref= "/about">About</a> <ahref= "/about?page=1">About</a> <ahref= "/about?page=1"ID= "Link1">About</a>
3. Form form
< Div > @using (Html.BeginForm ("Other", "Home", FormMethod.Post, new {id = "myForm"})) { } </div>
Build Result:
<div> <form action= "/home/other" id= "MyForm" method= "POST" ></form> </div>
4.TextBox and Textboxfor
The difference between a TextBox and a TextBox is that the value of the model field can be stored in the textboxfor, and the textbox cannot be
<Div>@Html. TextBox ("Txtname", "Chenchunxiao", new {style = "width:300px"}) @Html. textboxfor (A = A.cate Goryname, new {@style = "width:300px;"}) </Div>Generate Results<inputID= "Txtname"name= "Txtname"style= "width:300px"type= "text"value= "Chenchunxiao" /> <inputID= "CategoryName"name= "CategoryName"style= "width:300px;"type= "text"value= "Beverages" />
Reference
Commonly used: http://www.cnblogs.com/fishtreeyu/archive/2011/03/23/1992498.html
Extension method: http://www.cnblogs.com/wenjiang/archive/2013/03/30/2990854.html
Http://www.cnblogs.com/longgel/archive/2010/02/03/1662894.html
How to use ASP. NET Mvc-htmlhelper