mvc html.actionlink,LinkExtensions.ActionLink Method (System.Web.Mvc.Html) | Microsoft Docs

本文档详细介绍了 ASP.NET MVC 中的 ActionLink 辅助方法,用于生成 HTML 锚点元素。提供了多个重载版本,分别用于指定链接文本、操作、控制器、路由值和 HTML 属性,支持构建动态链接。
摘要由CSDN通过智能技术生成

LinkExtensions.ActionLink Method

Definition

Assembly:System.Web.Mvc.dll

Package:Microsoft.AspNet.Mvc v5.2.6

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

In this article

Overloads

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

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

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

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

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

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.

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

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.

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

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.

ActionLink(HtmlHelper, String, String)

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

public static System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, Object)

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

public static System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, object routeValues);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * obj -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, routeValues As Object) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

routeValues

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

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, String)

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

public static System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * string -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, controllerName As String) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

controllerName

The name of the controller.

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, RouteValueDictionary)

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

public static System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, System.Web.Routing.RouteValueDictionary routeValues);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * System.Web.Routing.RouteValueDictionary -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, routeValues As RouteValueDictionary) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

An object that contains the parameters for a route.

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, Object, Object)

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

public static System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * obj * obj -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, routeValues As Object, htmlAttributes As Object) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

routeValues

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

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

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, RouteValueDictionary, IDictionary)

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 System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, System.Web.Routing.RouteValueDictionary routeValues, System.Collections.Generic.IDictionary htmlAttributes);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * System.Web.Routing.RouteValueDictionary * System.Collections.Generic.IDictionary -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, routeValues As RouteValueDictionary, htmlAttributes As IDictionary(Of String, Object)) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

An object that contains the parameters for a route.

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

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, String, Object, Object)

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

public static System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * string * obj * obj -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, controllerName As String, routeValues As Object, htmlAttributes As Object) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

controllerName

The name of the controller.

routeValues

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

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

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, String, RouteValueDictionary, IDictionary)

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 System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues, System.Collections.Generic.IDictionary htmlAttributes);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * string * System.Web.Routing.RouteValueDictionary * System.Collections.Generic.IDictionary -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, controllerName As String, routeValues As RouteValueDictionary, htmlAttributes As IDictionary(Of String, Object)) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

controllerName

The name of the controller.

An object that contains the parameters for a route.

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

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, String, String, String, String, Object, Object)

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 System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * string * string * string * string * obj * obj -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, controllerName As String, protocol As String, hostName As String, fragment As String, routeValues As Object, htmlAttributes As Object) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

controllerName

The name of the controller.

protocol

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

hostName

The host name for the URL.

fragment

The URL fragment name (the anchor name).

routeValues

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

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

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

ActionLink(HtmlHelper, String, String, String, String, String, String, RouteValueDictionary, IDictionary)

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 System.Web.Mvc.MvcHtmlString ActionLink (this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, System.Web.Routing.RouteValueDictionary routeValues, System.Collections.Generic.IDictionary htmlAttributes);

static member ActionLink : System.Web.Mvc.HtmlHelper * string * string * string * string * string * string * System.Web.Routing.RouteValueDictionary * System.Collections.Generic.IDictionary -> System.Web.Mvc.MvcHtmlString

Public Function ActionLink (htmlHelper As HtmlHelper, linkText As String, actionName As String, controllerName As String, protocol As String, hostName As String, fragment As String, routeValues As RouteValueDictionary, htmlAttributes As IDictionary(Of String, Object)) As MvcHtmlString

Parameters

htmlHelper

The HTML helper instance that this method extends.

linkText

The inner text of the anchor element.

actionName

The name of the action.

controllerName

The name of the controller.

protocol

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

hostName

The host name for the URL.

fragment

The URL fragment name (the anchor name).

An object that contains the parameters for a route.

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

Returns

An anchor element (a element).

Exceptions

The linkText parameter is null or empty.

Applies to

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值