Jeremy
Jeremy

Reputation: 2536

ASP.NET MVC how to insert other html element inside @HTML.ActionLink

Normally, i would write something like this:

<li>@Html.ActionLink("Dashboard", "Index", "Account")</li>

To generate this:

<a href="/Account">Dashboard</a>

What i want to know is whether it is possible to generate the following HTML

<a href="#"><i class="fa fa-dashboard"></i> Dashboard</a>

Without having to create my own custom TagBuilder class.

Thanks for the help.

Upvotes: 2

Views: 2825

Answers (1)

Zabavsky
Zabavsky

Reputation: 13640

You can use UrlHelper.Action to generate the url:

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

Upvotes: 12

Related Questions