ActionLink with Image in ASP.NET MVC 2

As far as I know, this is one of the simplest ways to insert an ActionLink into your ASP.NET MVC 2 View with an image instead of text:

<a href="<%: Url.Action("Detail", new  { param1 = "blah" } )  %>">
  <img src="../../Content/images/magnifier.png" />

Any simpler solutions?

3 thoughts on “ActionLink with Image in ASP.NET MVC 2”

  1. Here is my code for ActionLink in MVC 3 with Razor engine.

    @Html.ActionLink(" ", "Edit", new { id = item.Id },
    new { @class = "edit-item-link", @title = "Edit" })

    Link text is empty.

    And here is CSS class which adds image:

    display: block;
    width: 16px;
    height: 16px;
    background-image: url(images/edit.png);

    Only if CSS is not enabled it will not work 🙁

  2. Did it actually work for you ? For me it doesn’t, displays nothing unless I do put some string as first parameter. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.