Tuesday, November 7, 2017

Add glyphicon to Html.ActionLink() in ASP.NET MVC

Hello,
Here's how to integrate glyphicon to Html.ActionLink() helper in ASP.NET MVC. The code below will display the glyphicon shopping cart right after the text Checkout of the anchor element.
@Html.ActionLink("Checkout", "Index", "Home", null, new { @class = "btn btn-info glyphicon glyphicon-shopping-cart" })
In order to add the glyphicon before the text of the anchor element, use @Url.Action() instead.
<a href="@Url.Action("Index", "Checkout")" class="btn btn-info">
 <span class="glyphicon glyphicon-shopping-cart" ></span>Checkout
</a>
Output:

0 comments:

Post a Comment