MVC @ Html. Raw () usage, mvc@html.raw usage

Source: Internet
Author: User
Tags actionlink

MVC @ Html. Raw () usage, mvc@html.raw usage

@ Html. Raw () method outputs a string with html tags,

For example: @ Html. Raw ("<div style = 'color: red'> output string </div> ")

Result: The output string is a string in red)

Use Html. Raw in Razor (this method is recommended)

  Summary of Html. ActionLink usage1. Html. the first parameter of ActionLink ("linkText", "actionName") is the text to be displayed. The second parameter is the view name, for example, <% = Html. actionLink ("Jump to About page", "About"); %> → <a href = "/Home/About"> jump to the About page </a> 2. Html. actionLink ("linkText", "actionName", "controlName") first parameter: the text to be displayed, second parameter: View name, third parameter: controller name for example: <% = Html. actionLink ("jump to another controler", "Index", "Home "); %> → <a href = "/Home/Index"> jump to another controler. </a> 3. Html. actionLink ("linkText", "actionName", routeValues) The first parameter is the text to be displayed. The second parameter is the view name. The third parameter is the url parameter <% = Html. actionLink ("Jump to the About page", "About", new {id = "1", name = "x "}) %> → <a href = "/Home/About/1? Name = x "> jump to the About page </a> 4. Html. actionLink ("linkText", "actionName", routeValues, htmlAttributes) first parameter: Text to be displayed, second parameter: View name, third parameter: parameter in url, fourth parameter: Set tag attributes such as: <% = Html. actionLink ("Jump to the About page", "About", new {id = "1", name = "x"}, new {disabled = "disabled ", @ class = "about"}) %> → <a class = "about" disabled = "disabled" href = "/Home/About/1? Name = x "> jump to the About page </a> Note: When setting the class attribute of a tag, add @ before the class because the class is a keyword.

Related Article

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.