#Eval图像数据 [英] #Eval image data
本文介绍了#Eval图像数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用eval为SQL VARBINARY数据(图像)结合的形象?
事情是这样的:
<图像SRC =<%#的eval(imageBinaryData)%> />
解决方案
您需要使用的HttpHandler来获取数据和流回来。那么你会从你的ASPX页面链接到处理程序。
< IMG类=mainEventsImage
SRC ='&下;%#评估和演示(MainImagePath)的ToString()更换(\\\\,/)%方式>。
ALT ='<%#的eval(标题)%GT;' =服务器/>如果(reader.Read())
{
INT缓冲区大小= 100;
字节[]字节=新的字节[缓冲区大小]
长读取动作;
长readFrom = 0; 做
{
读取动作= reader.GetBytes(0,readFrom,字节,0,缓冲区大小);
context.Response.ContentType =图像/ JPEG;
context.Response.BinaryWrite(字节);
readFrom + =缓冲区大小;
}
而(读取动作==缓冲区大小);
}
reader.Close();
How can I use Eval for binding sql varbinary data (images) to image? Something like this:
<image src = <%# Eval("imageBinaryData") %> />
解决方案
You need to use a HttpHandler to fetch the data and stream it back. You would then link to the handler from your ASPX page.
<img class="mainEventsImage"
src='<%# Eval("MainImagePath").ToString().Replace("\\", "/") %>'
alt='<%# Eval("Title") %>' runat="server" />
if (reader.Read())
{
int bufferSize = 100;
byte[] bytes = new byte[bufferSize];
long bytesRead;
long readFrom = 0;
do
{
bytesRead = reader.GetBytes(0, readFrom, bytes, 0, bufferSize);
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite(bytes);
readFrom += bufferSize;
}
while (bytesRead == bufferSize);
}
reader.Close();
这篇关于#Eval图像数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文