microtuts

ASP.NET MVC: Adding a Class to a Razor Html.ActionLink

I got a little tripped up trying to add a “class” attribute to my link created by the ActionLink HtmlHelper. It turns out “class” is a reserved word and you need to prefix it with the “@” symbol. Take a look:

Also not that if you have an attribute with a dash (-) in it you need to replace it with an underscore (_). It will be converted back to a dash when rendered.


Creating your first programming language is easier than you think.

Understanding how a programming language works is a surefire way to be a better developer. Read more.


Suggested Reading


written by Ryan Bosinger
Ryan is a web developer living and working in Banff Alberta. He also writes for giftsforpeoplewitheverything.com and freefoley.com.

One Response to “ASP.NET MVC: Adding a Class to a Razor Html.ActionLink”

Leave a Reply