user2567619 user2567619 - 7 months ago 33
HTML Question

how to generate Html.ActionLink with icon

I'm starting to learn ASP.NET MVC, and have a problem, how generate code with

Html.ActionLink
like this:

<a href="~/Views/Home/Create.cshtml" class="btn btn-primary">
<i class="icon-pencil icon-white"></i>
<span>
<strong>Create</strong>
</span>
</a>


please.

Answer

Html.ActionLink() only supports plain-text links.

You should use <a href="@Url.Action(...)"> for more-complex links.