Reputation: 943
In ASP.NET MVC view helper, you can do something like
<%= Html.ActionLink("click me", "DoSomething", null, new { someAttribute = "a value" } ) %>
which will produce the following HTML
<a href="DoSomething" someAttribute="a value">click me</a>
My question is.... what if I want to set the "class" attribute?
<%= Html.ActionLink("click me", "DoSomething", null, new { class = "a-class-name" } ) %>
That won't compile because "class" is a reserved word.
Is there a work-around?
Upvotes: 2
Views: 1412
Reputation: 1038780
Yes, using the @ literal:
<%= Html.ActionLink("click me", "DoSomething", null,
new { @class = "a-class-name" } ) %>
Upvotes: 12