ASP.NET MVC将css类添加到actionlink

Cam*_*ron 39 asp.net-mvc actionlink

如何将css类添加到此actionlink?我已经读过你这样做new { class = button }但我不知道把它放在我的actionlink中:

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

Bal*_*a R 85

你可以试试

<%= Html.ActionLink("View Performances", "Details", "Productions", 
        new { name = item.show , year = item.year }, 
        new {@class = "button"}) %>
Run Code Online (Sandbox Code Playgroud)

  • 谢谢你!如果您不想传递变量,可以执行以下操作:Html.ActionLink("查看性能","详细信息","制作",空,新{@class ="按钮"})如果您只是想要添加课程.此外,不需要此元素的"Productions"部分. (3认同)