0

I need to add an icon near myLink in razor view, in .html page i use ` Requête optimisée. Now i have

 @Html.ActionLink("Requete optimisée", "Index", "Requete")

Dont know where to add my icon .

Redadublex
  • 129
  • 6
  • 18
  • you can write a custom helper see :http://stackoverflow.com/questions/28893721/render-link-containing-span-in-asp-net-mvc-razor and also check this :http://stackoverflow.com/questions/23535704/image-button-in-actionlink-mvc – Ehsan Sajjad Mar 16 '15 at 12:16

2 Answers2

3

I wouldn't use ActionLink and would do the following:

<a href="@Url.Action("Index","Requete")" class="my-link-class">Requete optimisée
<div class="my-icon"><img src="@Url.Content("~/icon.jpg")" alt="Icon Image" /></a>

More code but also more freedom and control over what is going on.

scgough
  • 5,099
  • 3
  • 30
  • 48
1

If you want show an icon just put a img tag before your link:

<img src="~/Content/Images/Image.png" />
@Html.ActionLink("Requete optimisée", "Index", "Requete")

And if you want to display image link then use this:

@Html.ActionImage("Requete optimisée", "Requete", "~/Content/Images/Image.png")
BabyDuck
  • 1,249
  • 1
  • 9
  • 22