我正在使用Ajax.Actionlink
来自 MVC 框架的,一切都适用于我的目标和部分视图。但是我已经看到 html 输出没有将“id”属性添加到结果<a href=""></a>
标记中。
有什么办法可以添加吗?
我正在使用Ajax.Actionlink
来自 MVC 框架的,一切都适用于我的目标和部分视图。但是我已经看到 html 输出没有将“id”属性添加到结果<a href=""></a>
标记中。
有什么办法可以添加吗?
尝试其中一种重载,例如:
public static string ActionLink(
this AjaxHelper ajaxHelper,
string linkText,
string actionName,
Object routeValues,
AjaxOptions ajaxOptions,
Object htmlAttributes
)
然后可以在htmlAttributes参数中指定id,例如
new { id = "myIdValue" }
您需要new { id = "myId" }
在对象中使用 htmlAttributes 参数,该参数在其几个构造函数中可用。或者,您可以使用它的IDictionary<string, string>
几个构造函数中也可用的 htmlAttributes 来填充它。
我相信您正在寻找 routeValues 参数。
<%= Ajax.ActionLink("SomeAction", "SomeController", new { id = ID_HERE }, null) %>