Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a css class with Html.RouteLink

Tags:

asp.net-mvc

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.

like image 866
Raoul Avatar asked Oct 31 '08 10:10

Raoul


2 Answers

Just use uppercase for html attribute, like this:

<%= Html.RouteLink("Default", "Default",null, new { Class="css_class"}) %>
like image 30
Hrvoje Hudo Avatar answered Sep 16 '22 22:09

Hrvoje Hudo


Try this:

<%= Html.RouteLink("Default", "Default",null, new { @class="css_class"}) %>
like image 170
Robert Dean Avatar answered Sep 20 '22 22:09

Robert Dean