How do I add a class to an @Html.ActionLink?

You have to use the @ character, since class is a keyword in C#. Here’s a link to the MSDN documentation: http://msdn.microsoft.com/en-us/library/dd492124(v=vs.108).aspx

@Html.ActionLink("Link Text", "ActionName", 
         new { controller = "MyController", id = 1 }, 
         new { @class = "my-class" })

Leave a Comment