I need to know how to add a image in @Html.ActionLink
The code I have is:
@Html.ActionLink("IMAGE","Index","Home");
How to replace the IMAGE with an URL where my image is residing.
I need to know how to add a image in @Html.ActionLink
The code I have is:
@Html.ActionLink("IMAGE","Index","Home");
How to replace the IMAGE with an URL where my image is residing.
Use @Url.Action
instead:
<a href='@Url.Action("Index", "Home")'>
<img src="IMAGE PATH HERE" />
</a>
You have one of 2 options
<a href="@Url.Action("Index", "Home")" >
<img src="IMAGE" />
</a>
OR add a class and use the class to define the image
@Html.Action("Text", "Index", "Home", new {Class = "image-link"});
Use this
<a href="<%: Url.Action("Action", "Controller")%>"><img src="yourimg.jpg" /></a>
Use @Url.Action on Razor :
<img src="@Url.Action("ActionName", "ControlName", new { Model.ImageId })" />