2011-04-09 61 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