0

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?

7
  • Is your image displaying correctly? What is the URL that is getting 404? Commented May 6, 2013 at 5:15
  • the image is fine but when I click on the image, no matter the url I choose, I get a 404 Commented May 6, 2013 at 5:17
  • What is the URL that it is attempting? Commented May 6, 2013 at 5:22
  • <a href="~/Views/Shared/_index"><img...></a> . I've tried other views but can't seem to get it to display. Commented May 6, 2013 at 5:24
  • 1
    Try <a href="@Url.Action("Action", "Controller")"><img /></a> Commented May 6, 2013 at 5:34

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.