How to add span tag to tag using Html.ActionLink

How to add span tag inside a tag using Html.ActionLink ? Is something like this possible?

I am using ASP.NET MVC 4 along with Twitter Bootstrap version 3 .

I have a drop down menu and the HTML looks like this:

 <ul class="nav navbar-nav"> <li class="@(Model.Equals("Home") ? "active" : "")"> <a href="#"> <span class="glyphicon glyphicon-home"></span> Home </a> </li> </ul> 

I wanted to make the link as follows:

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

But in mixing things up, there is a span tag that makes it a little more complicated.

Perhaps I can also use the following:

 <a href="@Url.Action("Index", "Home")"> <span class="glyphicon glyphicon-home"></span> Home </a> 

Curious to know if the above is possible?

+6
source share
1 answer

Your option with Url.Action("Index", "Home") is correct and possible. Url.Action returns a URL, so it can be used in href.

+2
source

Source: https://habr.com/ru/post/957882/


All Articles