MVC Html.ActionLink

Source: Internet
Author: User
Tags actionlink

Html.ActionLink

In the Linkextensions class, the ActionLink method parameter description:

In a nutshell, it's like this.

Parameter type description

LinkText the text displayed by the link generated by the string

ActionName string corresponding to the Controller method

Controllername string Specifies the name of the controller

Protocol string specifies the Access protocol

HostName string specifies access to the domain name

Fragment string specifies access to the anchor point

Routevalues routevaluedictionary The arguments passed to the corresponding action

or object

Htmlattributes object or IDictionary properties of settings <a> tags

Overload one:

@Html. ActionLink ("linkText", "actionname")

Cases:

Build Effect:

Overload two:

@Html. ActionLink ("linkText", "actionname", routevalues)

Routevalues is an object:

Cases:

Build Effect:

Routevalues is routevaluedictionary:

Cases:

Build Effect:

Overload three:

@Html. ActionLink ("linkText", "actionname", routevalues,htmlattributes)

Htmlattributes is an object:

Cases:

Build Effect:

Htmlattributes is IDictionary:

Cases:

Build Effect:

Overload four:

@Html. ActionLink ("linkText", "actionname", "Controllername")

Cases:

Build Effect:

Overload five:

@Html. ActionLink ("linkText", "actionname", "controllername", "routevalues", " Htmlattributes ")

Both Htmlattributes and routevalues are object:

Example:

Build Effect:

Note: if written new{target= "_blank", class= "ClassName"} will error, because class is the keyword, so should be written like this → @class = "className"

Htmlattributes is IDictionary and routevalues is routevaluedictionary:

Example:

Build Effect:

There are only a few overloads listed above, and you want to know more about this class under the namespace namespace System.Web.Mvc.Html LinkExtensions.cs

MVC Html.ActionLink

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.