HTML5 allows the use of custom attributes prefixed with the phrase \"data-\" which pass validation without the use of a custom DTD (more info). In Asp.Net MVC, is there any
or you can use
new { data_customattribute="value" }
and the compiler is smart enough to know what you mean
Yes, there is an overload for ActionLink
method which takes an IDictionary<string,object>
instead of an anonymous object.
<%=Html.ActionLink("text", "Index", "Home", null /*routeValues*/,
new Dictionary<string, object> {
{ "data-customattribute", "value" },
{ "data-another", "another-value" }
})%>
Outputs :
<a data-another="another-value" data-customattribute="value" href="/">text</a>