2011-04-09 25 views
30

如何添加一个css类到这个动作链接?我看过你做的东西像new { class = button }但我不知道在哪里把它放在我的ActionLink内:ASP.NET MVC添加css类到动作链接

<%= Html.ActionLink("View Performances", "Details", "Productions", 
        new { name = item.show , year = item.year }, null) %> 

回答

69

你可以尝试

<%= Html.ActionLink("View Performances", "Details", "Productions", 
     new { name = item.show , year = item.year }, 
     new {@class = "button"}) %> 
+2

感谢这个! 如果您不想传递变量,您可以执行以下操作: Html.ActionLink(“View Performances”,“Details”,“Productions”, null,new {@class =“button”}) 如果你只是想添加类。此外,该元素的“制作”部分不是必需的。 – Termato 2013-12-31 19:29:19