Вопрос

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?

Это было полезно?

Решение

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>
}  
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top