将类添加到@ Html.ActionLink

时间:2014-01-29 22:23:41

标签: c# asp.net asp.net-mvc-4

如何在此@ Html.ActionLink中添加一个类?我已经尝试了许多建议,到目前为止还没有任何建议。

                        @Html.ActionLink("Physician Profile",
                                     "Print",
                                     "Roster",
                                     new { profilePrintType = ProfilePrintType.PhysicianProfile},
                                     new { style="padding:2px 10px;" })

2 个答案:

答案 0 :(得分:4)

对于保留字,您必须添加@

new { @style="padding:2px 10px;", @class = "className" })

答案 1 :(得分:2)

@Html.ActionLink("Physician Profile",
  "Print",
  "Roster",
  new { profilePrintType = ProfilePrintType.PhysicianProfile},
  new { style="padding:2px 10px;", @class = "some-css-class" })