Ajax.Actionlink output with id attribute
I'm using the Ajax.Actionlink
from the MVC framework and everything works fine with my targets and partial views. However I've seen that the html output doesn't add the "id" attribute to the resulting <a href=""></a>
tag.
Is there any way how 开发者_高级运维I can add it?
Try one of the overloads, like this one:
public static string ActionLink(
this AjaxHelper ajaxHelper,
string linkText,
string actionName,
Object routeValues,
AjaxOptions ajaxOptions,
Object htmlAttributes
)
Then you can specify the id in the htmlAttributes parameter, e.g.
new { id = "myIdValue" }
You need to use new { id = "myId" }
in the object htmlAttributes parameter, available in several of its constructors. Or you can fill it using the IDictionary<string, string>
htmlAttributes also available in several of its constructors.
I believe you're looking for the routeValues parameter.
<%= Ajax.ActionLink("SomeAction", "SomeController", new { id = ID_HERE }, null) %>
精彩评论