Introduction to ASP. 7, Hellper and data submission and binding

Source: Internet
Author: User

  1. View views We can write HTML code, or we can use the helper class provided by the base class to complete the HTM code.
  2. Example:<%=Html.ActionLink ("Home","Index", "home ") %>

    The generated HTML code is: <a href= "/home/index" > Home </a>

  3. The generated HTML code depends on the route order configured in Global.asax.
  4. Data display
  5. 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>

  6. 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" });}

  7. The above 4/5 items call different action methods with different httpmethod of the same action. (Attention: [ActionName ("Setting"), Acceptverbs ("POST")])
  8. The Updatemodel () method in data submission.

Reference: http://www.cnblogs.com/QLeelulu/archive/2008/10/05/1303991.html

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.