Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
ASP.NET
ASP.NET MVC 1.0
ActionLink Method
Collapse All/Expand All Collapse All
Members FilterMembers Filter
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
LinkExtensions..::.ActionLink Method

Returns an anchor element (a element) that contains the virtual path of the specified action.

  NameDescription
Public method Static member ActionLink(HtmlHelper, String, String) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, Object) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, String) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, RouteValueDictionary) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, Object, Object) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>)) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, String, Object, Object) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>)) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, String, String, String, String, Object, Object) Returns an anchor element (a element) that contains the virtual path of the specified action.
Public method Static member ActionLink(HtmlHelper, String, String, String, String, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>)) Returns an anchor element (a element) that contains the virtual path of the specified action.
Top

The ActionLink method renders an element that links to an action method. The RouteLink method renders an element that links to a URL, which could resolve to an action method, a file, a folder, or some other resource.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
the ActionLink descriptions on this page need improvement!      gerry lowry ... Thomas Lee   |   Edit   |   Show History
Multiple forms (10) of ActionLink are currently (2009-08-19) shown on this page.
ALL ten forms have the same generalized description:
"Returns an anchor element (a element) that contains the virtual path of the specified action."

For ActionLink(HtmlHelper, String, String) :

The first parameter HtmlHelper can be ignored in
<%= Html.ActionLink( ... ) %>
[see the Usage Note at http://msdn.microsoft.com/en-us/library/dd493018.aspx]

The second parameter string is the linkText, your choice, pick something meaningful:
<%= Html.ActionLink("register to vote", ... ) %>

The third parameter string is the actionName, example:
<%= Html.ActionLink("register to vote", "Register") %>

For ...........................linkText - action - controller
ActionLink(HtmlHelper, String, String, String),
ActionLink(HtmlHelper, String, String, String, Object, Object),
ActionLink(HtmlHelper, String, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>)),
ActionLink(HtmlHelper, String, String, String, String, String, String, Object, Object),
ActionLink(HtmlHelper, String, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>)),
ActionLink(HtmlHelper, String, String, String, String, String, String, Object, Object), and
ActionLink(HtmlHelper, String, String, String, String, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>))
in each case the fourth string is the controllerName, example:
<%= Html.ActionLink("register to vote", "Register", "Account") %>

The linkText and the actionName must always be specified
and are always in the same position.

With , Object, Object
the first Object represents routeValues and
the second Object represents htmlAttributes

The good thing is that there is consistency once the developer recognizes
the patterns that the parameters tend to follow. This makes it easier for
the more experienced developers to guess; however, this documentation
is also provided for less experienced developers and needs to address
their needs too.

By following the links from this page, the developer can recognize the pattern.
imo, it would be better documentation to not force the developer to jump
all over the place; also, there needs to be better examples so the developer
can more quickly determine how the various forms are actually used in code.

Gerry Lowry
gerry.lowry@abilitybusinesscomputerservices.com
hidden links on this page (2009-08-19)      gerry lowry ... Thomas Lee   |   Edit   |   Show History

ActionLink(HtmlHelper, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>))
[ http://msdn.microsoft.com/en-us/library/dd504988.aspx ]

ActionLink(HtmlHelper, String, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>))
[ http://msdn.microsoft.com/en-us/library/dd493068.aspx ]

ActionLink(HtmlHelper, String, String, String, String, String, String, RouteValueDictionary, IDictionary<(Of <(String, Object>)>))
[ http://msdn.microsoft.com/en-us/library/dd492938.aspx ]

You can find the missing links on the printer friendly version of this page:

http://msdn.microsoft.com/en-us/library/system.web.mvc.html.linkextensions.actionlink(printer).aspx

Gerry Lowry
gerry.lowry@abilitybusinesscomputerservices.com

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker