从二进制数据转换为ASP.NET图像控件 [英] Convert from binary data to an image control in ASP.NET

查看:216
本文介绍了从二进制数据转换为ASP.NET图像控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形象的二进制数据在我的数据库,我想在ASP.NET图像控件来显示它。怎么样?如果它是不可能的,请找到另一种方式将其保存在数据库中,在图像控件中显示它。

I have binary data of an image in my database, and I want to display it in an image control in ASP.NET. How? If it is impossible, please find another way to save it in the database and display it in an image control.

推荐答案

创建一个普通的HTML IMG 像这样的元素:

Create a regular HTML img element like so:

<img runat="server" id="image" />

和背后为此在 code:

And in code behind do this:

image.src = "data:image/png;base64," + Convert.ToBase64String(imageBytes);

在哪里imageBytes是字节[]

您完成。图像将显示出来。

You are done. The image will be displayed.

这篇关于从二进制数据转换为ASP.NET图像控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆