rogerthat
rogerthat

Reputation: 1815

making an image link from a db asp.net mvc 4

I have this foreach loop pulling images from my db :

     `@foreach (var item in model)
     <tr>
     <td>
     <img width="50" height="50" src="@Url.Action("GetImage", "Product", new { item.ProductId})"/>
     </td>
     ...`

I tried to wrap it in an 'a' tag but all I get is 404's.

    <a href = "~/..."> <img width="".../></a>

Any ideas?

Upvotes: 0

Views: 876

Answers (1)

von v.
von v.

Reputation: 17108

an image with a hyperlink is what I'm trying to achieve. You click the image and you're taken to the edit page.

Okay so suppose you get the image as shown in your question Product.GetImage and then the edit page is called by Product.Edit, you can have this:

<a href="@Url.Action("Edit")"><img src="@Url.Action("GetImage","Product")" /></a>

Upvotes: 1

Related Questions