Dofactory.com
Dofactory.com
 Back to list
Views:   109K
Replies:  1
Archived

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.
 
Deshaun Hyram, Feb 19, 2010
Reply 1
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" } ) %> 

 
Andrey Lesch, Feb 23, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.