41

How do I add a css class to this actionlink? I have read you do it something like new { class = button } but I'm not sure where to put it within my actionlink:

<%= Html.ActionLink("View Performances", "Details", "Productions", 
                    new { name = item.show , year = item.year }, null) %>
KyleMit
  • 30,350
  • 66
  • 462
  • 664
Cameron
  • 27,963
  • 100
  • 281
  • 483

1 Answers1

94

you can try

<%= Html.ActionLink("View Performances", "Details", "Productions", 
        new { name = item.show , year = item.year }, 
        new {@class = "button"}) %>
Bala R
  • 107,317
  • 23
  • 199
  • 210
  • 5
    Thanks for this! If you do not want to pass in a variable you can do the following: Html.ActionLink("View Performances", "Details", "Productions", null, new {@class = "button"}) if you just want to add the class. Also, the "Productions" part of this element is not required. – Termato Dec 31 '13 at 19:29