tags:

views:

846

answers:

3

Hi,

Does anyone know how I can add a class to the link rendered using the Html.RouteLink helper method in ASP.Net MVC, it has the htmlAttributes object as the last parameter which I assumed I would be able to use, but since class is obviously a reserved word, I cannot supply this as one of the properties on the object.

+2  A: 

just use uppercase for html attribute, like this:

<%= Html.RouteLink("Default", "Default",null, new { Class="css_class"}) %>

Hrvoje
+3  A: 

Yes that does work, but unfortunately this now means that my html no longer validate as xhtml strict due to the case. Ideally I would like to find a solution which doesn't involve compromising the markup.

Raoul
+17  A: 

try this

        <%= Html.RouteLink("Default", "Default",null, new { @class="css_class"}) %>
robDean