Question

I have a question about using an image as link to a specific action in a controller.
I load my images from the database and show them in a view:

@foreach(var imgID in Model.DeliverablesIDsList)
{
    <div class='small-3 columns'>
        <img src="@Url.Action("ShowImage", "Deliverable", new { DeliverableID = imgID })" />
    </div>
}   
</div>

Now I would like to have a link around that image so that I can link to a view and send the linked DeliverableID with it.

How can I do this?

Était-ce utile?

La solution

You should try this.

@foreach(var imgID in Model.DeliverablesIDsList)
{
    <div class='small-3 columns'>
        <a href="@Url.Action("ShowImage", "Deliverable", new { DeliverableID = imgID })">
           <img src="image-url" />
        </a>
    </div>
}  
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top