• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2341
  • Last Modified:

In ASP.NET 4.0 MVC 3, How to make html.actionlink without text but with image inside. We do not want to create a helper class

Let me explain the scenario. We have a index page where we are displaying 4 products, and one of the sample product is attached as an image (product image). Along the product there is Details and Order now image button.
Click on Details image button will open a model popup containing details about the product, this also attached as product detail popup image

We are using ASP.NET 4.0 MVC 3 Razor View, The problem we are facing is we are not able to use HTML.Actionlink with image, were as with Text we are able to call model popup please have a look at my third attached product with text link image

We have googled for some solution, but every were they are mentioning to use helper class. We want to avoid it, if there are any other straight forward solution available.

Sincere appreciation for any help

  • 2
2 Solutions
<a href="<%= Url.Action("ActionName", "ControllerName") %>">
    <img src="<%= Url.Content("~/Content/img/imgname.jpg") %>" /></a>

Open in new window

Best regards,
Or you can try to do something like this
@Html.ActionLink(" ", "Edit", new { id = item.Id },
new { @class = "edit-item-link", @title = "Edit" })

Open in new window

Link text is empty.

And here is CSS class which adds image:

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

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now