Home  /  Questions  /  Question



121   96.7
Feb 19, 2010


Html.ActionLink and class attribute

How do I set the class attribute in Html.ActionLink.  When I include for htmlAttributes: new { class = "border" } I get a compiler error.
This is the full line:

<% = Html.ActionLink("TextLink", "Action", "Controller", new { class = "border" } ) %>
Thanks.
 



90   96.5
Feb 23, 2010
Hi Deshaun Hyram! But You cann't  use the word "class" because this is reserved keyword . You can try the variant below. For correct use you should be putting symbol "@" before the keyword "class".
<% = Html.ActionLink("TextLink", "Action", "Controller", new { @class = "border" } ) %> 

 
 2 comments
 
That is exactly what I needed! Thanks Andrey. --- Deshaun Hyram  Feb 23, 2010
 
You are welcome !!! --- Andrey Lesch  Feb 24, 2010