ASP. MVC5 Advanced Programming 5th Chapter forms and HTML helper methods

Source: Internet
Author: User
Tags http post

Reference "ASP. MVC5 Advanced Programming" version 5th

5th. Forms and HTML helper methods 5.1 using the 5.1.1 Action and Method properties

By default, the form sends an HTTP Post request

EF also has conventions for foreign key relationships, database names, and so on. These conventions supersede all the mappings and configurations that previously needed to be provided to a relational object mapping framework.

    • Get method: All parameters of a GET request are in the URL, so you can bookmark a GET request.
    • POST method: The browser puts the input values into the body of the HTTP request.
5.2 Auxiliary Methods

HTML helper methods can be called through the HTML properties of the view. The Ajax helper method can also be called through the URL property with the URL helper method, via Ajax properties.

5.2.1 Automatic Coding

The helper method HTML-encodes the value before outputting the model value, and the default encoding can help avoid cross-site scripting attacks.

The use of 5.2.2 auxiliary methods

We can use the Htmlattributes parameter to set many of the necessary attribute values.

How the 5.2.3 HTML helper method works

Each of the razor views inherits the HTML properties of their base class. The type of Html attribute is system.web.mvc.htmlhelper<t>.

5.2.4 setting up an edit form

The ValidationSummary helper method renders the CSS class validation-summary-errors along with any specific CSS classes provided.

5.2.5 Adding an INPUT element

1,html.text and Html.textarea

2,html.label

3,html.dropdownlist and Html.listbox

4,html.validationmessage

5.2.6 helper methods, models, and view data 5.2.7 Types of auxiliary methods

When you use a strongly typed helper method, you need to pass a lambda expression for it to specify the model properties that you want to render.

5.2.8 helper methods and model meta-data

Helper methods can take advantage of the resulting model metadata.

Auxiliary methods for 5.2.9 Templates 5.2.10 helper methods and ModelState5.3 other input helper methods 5.3.1 html.hidden5.3.2 html.password5.3.3 html.radiobutton5.3.4 html.checkbox5.4 Rendering helper methods 5.4.1 Html.ActionLink and html.routelink5.4.2 URL helper methods 5.4.3 Html.partial and Html.renderpartial

Html.partial contains 4 overloaded versions

5.4.4 Html.action and Html.renderaction

Reference "ASP. MVC5 Advanced Programming" version 5th

ASP. MVC5 Advanced Programming 5th Chapter forms and HTML helper methods

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.