ASP.NET MVC add css class to actionlink [duplicate]
Asked Answered
D

1

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) %>
Dumbhead answered 9/4, 2011 at 23:26 Comment(0)
C
94

you can try

<%= Html.ActionLink("View Performances", "Details", "Productions", 
        new { name = item.show , year = item.year }, 
        new {@class = "button"}) %>
Coronary answered 9/4, 2011 at 23:31 Comment(1)
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.Anaphylaxis

© 2022 - 2024 — McMap. All rights reserved.