Table of Contents

Class LinkExtensions

Namespace
System.Web.Mvc.Html
Assembly
System.Web.Mvc.dll

Represents support for HTML links in an application.

public static class LinkExtensions
Inheritance
LinkExtensions
Inherited Members

Methods

Returns an anchor element (a element) for the specified link text and action.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, and route values.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, route values, and HTML attributes.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

htmlAttributes object

An object that contains the HTML attributes for the element. The attributes are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, and controller.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

controllerName string

The name of the controller.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, controller, route values, and HTML attributes.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

controllerName string

The name of the controller.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, controller, protocol, host name, URL fragment, route values, and HTML attributes.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

controllerName string

The name of the controller.

protocol string

The protocol for the URL, such as "http" or "https".

hostName string

The host name for the URL.

fragment string

The URL fragment name (the anchor name).

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, controller, protocol, host name, URL fragment, route values as a route value dictionary, and HTML attributes as a dictionary.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

controllerName string

The name of the controller.

protocol string

The protocol for the URL, such as "http" or "https".

hostName string

The host name for the URL.

fragment string

The URL fragment name (the anchor name).

routeValues RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, controller, route values as a route value dictionary, and HTML attributes as a dictionary.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

controllerName string

The name of the controller.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, and route values as a route value dictionary.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

Returns an anchor element (a element) for the specified link text, action, route values as a route value dictionary, and HTML attributes as a dictionary.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

actionName string

The name of the action.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, object routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, object routeValues, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeName string

The name of the route that is used to return a virtual path.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, object routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeName string

The name of the route that is used to return a virtual path.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, object routeValues, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeName string

The name of the route that is used to return a virtual path.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeName string

The name of the route that is used to return a virtual path.

protocol string

The protocol for the URL, such as "http" or "https".

hostName string

The host name for the URL.

fragment string

The URL fragment name (the anchor name).

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeName string

The name of the route that is used to return a virtual path.

protocol string

The protocol for the URL, such as "http" or "https".

hostName string

The host name for the URL.

fragment string

The URL fragment name (the anchor name).

routeValues RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, RouteValueDictionary routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeName string

The name of the route that is used to return a virtual path.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeName string

The name of the route that is used to return a virtual path.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, RouteValueDictionary routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.

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

public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

linkText string

The inner text of the anchor element.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcHtmlString

An anchor element (a element).

Exceptions

ArgumentException

The linkText parameter is null or empty.