2011-09-27 37 views

回答

2

<td>標籤不能被用來顯示圖像。隨着中說,你這是怎麼從後面的代碼顯示在VB.NET的圖像:

在你的aspx頁面此類型的標記:

<td> 
<img src="" runat="server" id="imageFromDB" /> 
... 

可以在後面的代碼做到這一點:

Dim imageBytes() as Byte= ... // You got the image from the db here... 
//jpg is used as an example on the line below. 
//You need to use the actual type i.e. gif, jpg, png, etc. 
//You can do imageFromDB simply because you set runat="server" on the markup 
imageFromDB.src = String.Format("data:image/{0};base64, 
{1}","jpg",Convert.ToBase64String(imageBytes) 

這將在頁面上呈現您的圖像。

我希望在這裏給你足夠的信息。

1

參照樣品中的答案你提到:除非你把一個<img>元素裏面

<td><img src="PathToYourHttpHandler?id=ID_OF_YOUR_IMAGE" /></td> 
相關問題