I’ve got a HTML list of menu items generated by MVC 2.
<%= Html.MenuItem("Home", "Home", "Index")%>
<%= Html.MenuItem("Login", "Login", "Account")%>
Which generate in HTML:
<li>
<a href="Index">Home</a>
</li>
<li>
<a href="Account">Login</a>
</li>
How can I add a CSS class to the element in the list for each item in the list?
I am guessing this MenuItem is an extension method that you wrote or that you took from someone, I am also guessing that they are wrapping an ActionLink Method, As in:
if this is the case just make it take is a css class as a parameter and use the ActionLink that takes in htmlattributes, as in:
then you just call them like this: