Reputation: 235
I have an asp.net mvc4 application. in which i have to put a n image with the url to an action:
<a href="@Html.ActionLink("Retour","Retour","Client")"><img src="~/Content/images/home-icon.png" /></a>
but an error of invalid url is appears. So what is the reason of this error? how can i fix my code?
Upvotes: 0
Views: 2498
Reputation: 10824
you can use these ways
Method 1:
@Html.ActionLink("Retour","Retour","Client",null, new { @class="background" })
CSS :
a.background
{
background: url(../Images/image.gif) no-repeat top left;
display: block;
width: 150px;
height: 150px;
text-indent: -9999px; /* hides the link text */
}
Method 2:
<a href='@Url.Action("MyAction", "MyController")'>
<img src='@Url.Content("~/Content/Images/image.gif")' />
</a>
Method 3:
@Html.ActionLink("Retour","Retour","Client" , new {
style = "background: url('../../Content/Images/image.gif') no-repeat center right;display:block; height:24px; width:24px;"
} )
Upvotes: 4