Can I add a class to an HTML.ActionLink in MVC3

Yes, you can just add another parameter with object representing css class:

Html.ActionLink("Create New", "Create", CONTROLLERNAME, null, new { @class= "yourCSSclass"} )

It can be translated to:

Html.ActionLink(link text, action name, controller name, route values object, html attributes object)

Edit:

To add custom styles, use this:

Html.ActionLink(
"Create New",
"Create",
CONTROLLERNAME,
null,
new { @class= "yourCSSclass", @style= "width:100px; color: red;" }
)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)