2013-05-06 83 views
0

我有這樣的foreach循環從我的分貝拉動圖片:使得從數據庫asp.net mvc的圖片鏈接4

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

我試圖把它包在一個「A」的標籤,但我得到的是404的。

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

任何想法?

+0

是您的正確的圖像顯示?什麼是獲得404的URL? – 2013-05-06 05:15:42

+0

圖像是好的,但當我點擊圖片時,無論我選擇的網址,我得到一個404 – rogerthat 2013-05-06 05:17:04

+0

它正在嘗試的URL是什麼? – 2013-05-06 05:22:17

回答

1

一個超鏈接的圖像是我想要實現的。您點擊 圖片,即可進入編輯頁面。

好吧,假設你得到的圖像,如圖你的問題Product.GetImage,然後在編輯頁面被稱爲Product.Edit,你可以有這樣的:

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

謝謝。讚賞 – rogerthat 2013-05-06 06:20:12

+0

不客氣。 – 2013-05-06 06:20:47