iNerd Blog

Image link in ASP.NET MVC

Posted in Programming by Ari on 9 April 2010
    <%= Html.ActionLink("Edit", "Edit", new { id=item.Id  }) %> |
    <%= Html.ActionLink("Delete", "Delete", new { id=item.Id  }) %>

This is how a normal link usually written. When you want a url to be embedded within an image it should be written like this:

   <a href='<%= Url.Action("Edit", new {id=item.Id}) %>'>
       <img src="../../Content/Edit.png" alt="Edit" /></a>
   <a href='<%= Url.Action("Delete", new {id=item.Id}) %>'>
       <img src="../../Content/Delete.png" alt="Delete" /></a>


Tagged with:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: