Reputation: 8805
Ok, I cant find the answer to this:
<%: Html.ActionLink("Click Here", "Action", null, new {class="myClass"})%>
I want to set the CSS class attribute of the generated element.
Obviously, C# will not allow me to use "class" as the name of an object's member.
What should I do?
Upvotes: 9
Views: 2101
Reputation: 5895
Using a capital 'C' in Class also works, from this answer to a similar question. The attribute names are converted to lower case.
<%: Html.ActionLink("Click Here", "Action", null, new { Class = "myClass" })%>
Upvotes: 0
Reputation: 3502
Can You try with escaping the class with : @.
So, please modify your code to :
<%: Html.ActionLink("Click Here", "Action", null, new {@class="myClass"})%>
Upvotes: 18