简体   繁体   English

我应该使用什么控件来显示保存在数据库中并编码为Image的图像

[英]What control should i use to display an image saved in database and encoded as Image

All is in the question. 一切都是问题。 I have an image saved in database in an Image column. 我在“图像”列中将图像保存在数据库中。 How could i manage to display it in an aspx page ? 我怎样才能在aspx页面中显示它?

The problem is i don't know how to display an image without specifing an Url. 问题是我不知道如何在不指定网址的情况下显示图像。 Thanks in advance for your help Have a nice day 预先感谢您的帮助祝您有美好的一天

编写一个处理程序,该处理程序根据URL参数返回特定的图像(将图像的字节数组写入响应中)并将其设置为Image控件的URL。

Create a HTTP handler and called the handler in the in every img scr 在每个img scr中创建一个HTTP处理程序并在中调用该处理程序

<img src="ShowImg.ashx?ID=imageid" alt="imgetitle" />

handler will load the image from the imageid passed as a querystring to it. 处理程序将从作为查询字符串传递给它的imageid加载图像。 on handler we will right the code to read the image from database and display on the page. 在处理程序上,我们将纠正代码以从数据库读取图像并显示在页面上。

You can do this with an HTTP Handler serving the image while referencing that handler in an html image tag. 您可以使用提供图像的HTTP处理程序,同时在html图像标签中引用该处理程序来执行此操作。

Take a look at this article for an example. 看看这个文章的一个例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM