Understanding the MVC programming model in ASP. 4th HTML Helper

Source: Internet
Author: User
Tags html form actionlink

The HTML helper is used to modify the HTML output.

HTML Helper

The HTML helper is used to modify the html,html helper without the event model and view state. In most cases, the HTML helper is simply a way to return a string.

Standard HTML Helper

MVC contains standard helpers for most common types of HTML elements, such as HTML links and HTML form elements.

HTML Links

The simplest way to render an HTML link is to use HTML. ActionLink () helper.

Does not connect to the view through Mvc,html.actionlink (). It creates a connection to the Controller action (Director action).

Razor Syntax:

@Html. ActionLink ("About the Website", "about")

The first parameter is the link text, and the second parameter is the name of the controller action.

Above the Html.ActionLink () helper, output the following Html:

<href= "/home/about">about this Website</a >

Some parameters of the Html.ActionLink () helper:

Parameters Description
LinkText The inner text of the anchor element.
ActionName The name of the action.
Controllername The name of the controller.
Protocol URL protocol, such as "http" or "https".
Hostname The host name of the URL.
Fragment The URL fragment name (anchor name).
Routevalues An object that contains the route parameters.
Htmlattributes An object that contains the HTML attributes to set for the element.

Note: You can pass a value to a controller action. For example, you can pass the ID of a database record like a database edit operation.

Razor Syntax C #:

@Html. ActionLink ("Edit Record", "edit", new {id=3})

Above the Html.ActionLink () helper, output the following Html:

<href= "/HOME/EDIT/3">Edit Record</a> 
HTML form Elements

The following HTML helper can be used to render (modify and Output) HTML form elements:

    • BeginForm ()
    • EndForm ()
    • TextArea ()
    • TextBox ()
    • CheckBox ()
    • RadioButton ()
    • ListBox ()
    • DropDownList ()
    • Hidden ()
    • Password ()

Understanding the MVC programming model in ASP. 4th HTML Helper

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.