문제

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