HtmlHelper.GenerateLink Method

 

Generates an HTML anchor element (a element) that links to an action method.

Namespace:   System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticGenerateLink(RequestContext, RouteCollection, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>)

Generates an HTML anchor element (a element) that links to the specified action method.

System_CAPS_pubmethodSystem_CAPS_staticGenerateLink(RequestContext, RouteCollection, String, String, String, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>)

Generates an HTML anchor element (a element) that links to the specified action method, and enables the user to specify the communication protocol, name of the host, and a URL fragment.

Return to top

HtmlHelper.GenerateLink Method (RequestContext, RouteCollection, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>)

Generates an HTML anchor element (a element) that links to the specified action method.

public static string GenerateLink(
	RequestContext requestContext,
	RouteCollection routeCollection,
	string linkText,
	string routeName,
	string actionName,
	string controllerName,
	RouteValueDictionary routeValues,
	IDictionary<stringobject> htmlAttributes
)

Parameters

requestContext
Type: System.Web.Routing.RequestContext

The context of the HTTP request.

routeCollection
Type: System.Web.Routing.RouteCollection

The collection of URL routes.

linkText
Type: System.String

The text caption to display for the link.

routeName
Type: System.String

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

actionName
Type: System.String

The name of the action method.

controllerName
Type: System.String

The name of the controller.

routeValues
Type: System.Web.Routing.RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes
Type: System.Collections.Generic.IDictionary<StringObject>

An object that contains the HTML attributes for the element.

Return Value

Type: System.String

An HTML element that links to the specified action method.

Return to top

HtmlHelper.GenerateLink Method (RequestContext, RouteCollection, String, String, String, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>)

Generates an HTML anchor element (a element) that links to the specified action method, and enables the user to specify the communication protocol, name of the host, and a URL fragment.

public static string GenerateLink(
	RequestContext requestContext,
	RouteCollection routeCollection,
	string linkText,
	string routeName,
	string actionName,
	string controllerName,
	string protocol,
	string hostName,
	string fragment,
	RouteValueDictionary routeValues,
	IDictionary<stringobject> htmlAttributes
)

Parameters

requestContext
Type: System.Web.Routing.RequestContext

The context of the HTTP request.

routeCollection
Type: System.Web.Routing.RouteCollection

The collection of URL routes.

linkText
Type: System.String

The text caption to display for the link.

routeName
Type: System.String

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

actionName
Type: System.String

The name of the action method.

controllerName
Type: System.String

The name of the controller.

protocol
Type: System.String

The communication protocol, such as HTTP or HTTPS. If this parameter is null, the protocol defaults to HTTP.

hostName
Type: System.String

The name of the host.

fragment
Type: System.String

The fragment identifier.

routeValues
Type: System.Web.Routing.RouteValueDictionary

An object that contains the parameters for a route.

htmlAttributes
Type: System.Collections.Generic.IDictionary<StringObject>

An object that contains the HTML attributes for the element.

Return Value

Type: System.String

An HTML element that links to the specified action method.

Return to top
Show: