user1323912
user1323912

Reputation:

How do i apply css to a actionlink in MVC

Below is my html link <a href="index.html"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>

How do i convert the above to the below action link with CSS (<i> tag) @Html.ActionLink("AppStore", "Index", "Home")

Please help..

Upvotes: 0

Views: 569

Answers (4)

user3450804
user3450804

Reputation: 83

       @Html.ActionLink("AppStore", "Index", "Home", new {ProductID = 73}, new {@class="fa fa-dashboard fa-fw"})

You have asked a question about which overload to choose .When you start the paranthesis "(" after @HTML.ActionLink you can scroll with the up and down arrow to see which overload works best for you .In case you would like to specify the productID etc ,you can do so by using the above code.

Upvotes: 0

Nitin Varpe
Nitin Varpe

Reputation: 10694

If you want to have html tag inside anchor tag use Url.Action instead

<a href="@Url.Action("Index", "Home") "><i class="fa fa-dashboard fa-fw"></i>Dashboard</a>

Correct overload for Html.Actionlink is

//linkText, actionName, controllerName, routeValues, htmlAttributes
@Html.ActionLink("AppStore", "Index", "Home", new object{}, new {class="fa fa-dashboard fa-fw"})

Upvotes: 0

Baahubali
Baahubali

Reputation: 4802

The following function tells you how to add css in your action link call.

@Html.Action("AppStore", "Index", "Home", New With {.class="cssvalue"})

The above syntax is vb.net

Upvotes: 0

you can do it like this

@Html.ActionLink("Name", "viewname", "Controllername", new {HTML Attributes here})

@Html.ActionLink("AppStore", "Index", "Home", new {@class="fa fa-dashboard fa-fw"})

Upvotes: 1

Related Questions