Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add class to @Html.ActionLink

How do I add a class to this @Html.ActionLink? I've tried many suggestion and none have worked so far.

                        @Html.ActionLink("Physician Profile",
                                     "Print",
                                     "Roster",
                                     new { profilePrintType = ProfilePrintType.PhysicianProfile},
                                     new { style="padding:2px 10px;" })
like image 514
Ronald McDonald Avatar asked Nov 17 '25 15:11

Ronald McDonald


2 Answers

for reserved words you have to add @

new { @style="padding:2px 10px;", @class = "className" })
like image 144
Matt Bodily Avatar answered Nov 20 '25 06:11

Matt Bodily


@Html.ActionLink("Physician Profile",
  "Print",
  "Roster",
  new { profilePrintType = ProfilePrintType.PhysicianProfile},
  new { style="padding:2px 10px;", @class = "some-css-class" })
like image 35
Mark Avatar answered Nov 20 '25 05:11

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!