- View views We can write HTML code, or we can use the helper class provided by the base class to complete the HTM code.
- Example:<%=Html.ActionLink ("Home","Index", "home ") %>
The generated HTML code is: <a href= "/home/index" > Home </a>
- The generated HTML code depends on the route order configured in Global.asax.
- Data display
- Data binding
<P> <label for= "Name">Name of the blog</label> <%=Html.textbox ("Name")%> <%=Html.validationmessage ("Name")%></P><P> <label for= "Description">A brief description of the blog</label> <%=Html.textarea ("Description")%> <%=Html.validationmessage ("Description")%></P><P> <label for= "Postsperpage">Number of logs displayed per page</label> <%=Html.textbox ("Postsperpage")%> <%=Html.validationmessage ("Postsperpage")%></P>
- Data submission
[ActionName ("Setting"), Acceptverbs ("POST")] PublicActionResult SaveSetting () {//of course, you can take that value .//String name = request.form["Name"]; //but we have a simpler one: Try{Updatemodel (blogsettings.instance,New[] {"Name","Description","Postsperpage" }); } Catch { returnView (blogsettings.instance); } //you may also need to validate your custom business logic hereBlogSettings.Instance.Save (); returnShowMsg (Newlist<string> () {"Modify settings successfully" });}
- The above 4/5 items call different action methods with different httpmethod of the same action. (Attention: [ActionName ("Setting"), Acceptverbs ("POST")])
- The Updatemodel () method in data submission.
Reference: http://www.cnblogs.com/QLeelulu/archive/2008/10/05/1303991.html