Introduction to HTML. actionlink in MVC)

Source: Internet
Author: User
Tags actionlink

1,Html. actionlink ("linktext", "actionname ")

First parameter: Text to be displayed, second parameter: View name

example: <%= HTML. actionlink (" jump to about page ", "about "); %> → jump to about page

2,Html. actionlink ("linktext", "actionname", "controlname ")

First parameter: Text to be displayed, second parameter: View name, Third parameter: controller name

example: <%= HTML. actionlink (" jump to another controler medium ", "Index", "home") ;%> → jump to another controler medium

3,Html. actionlink ("linktext", "actionname", routevalues)

First parameter: Text to be displayed, second parameter: View name, Third parameter:URLParameters in

example: <%= HTML. actionlink (" jump to about page ", "about", new {id = "1", name = "X "}) %> → jump to about page

4,Html. actionlink ("linktext", "actionname", routevalues, htmlattributes)

First parameter: Text to be displayed, second parameter: View name, Third parameter:URLParameters in,Fourth parameter: Set tag attributes

For example: <% = Html. actionlink (" Jump 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 About Page </A>

note: set class attribute, class Add @, because class is a keyword.

<% = %> both can be replaced with <%: %>

"<%: %>"And"<% = %>"Differences:<%: %>PerformHtmlencodeEncoded to prevent cross-site scripting attacks (I .e:XSSAttack ).

<%: <Div> Display Div <Div >%> → <Div> Display Div <div> While <% = <Div> Display Div <Div >%> → Display Div

<%: %>When using a function, the function must have a return value. Otherwise, an error is returned.

Transferred from:Http://daociyiyou111.blog.163.com/blog/static/1647015122011930113339916/

 

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.