Kira
Kira

Reputation: 1207

changing an action link to an image

How could I change an action link @Html.ActionLink("Edit", "Edit", new { id=item.id_tache }) to an image. I'm just starting with asp .net mvc. (i want to display an image instead of text)

Upvotes: 0

Views: 914

Answers (2)

Yasser Shaikh
Yasser Shaikh

Reputation: 47784

Here is a small hack

@Html.ActionLink("Button Name", "Index", null, new { @class="classname" })

and then create a class in your stylesheet

a.classname
{
 background: url(../Images/image.gif) no-repeat top left;
 display: block;
 text-indent: -9999px; /* hides the link text */
 }

Upvotes: 2

SLaks
SLaks

Reputation: 887453

You need to make a regular link:

<a href="@Url.Action(...)"><img src="Url.Content("~/...")" alt="..." /></a>

Upvotes: 3

Related Questions