在ASP中显示图像:图像ASP.NET C# [英] Display image in ASP:image ASP.NET C#

查看:121
本文介绍了在ASP中显示图像:图像ASP.NET C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的sql server db中我有字段名stuimage类型图像

i想在asp中显示这个图像:asp.net中的图像id =image1c#

使用此代码



  byte  [] bytes =(字节 [])x.Student_Picture; 
string imgString = Convert.ToBase64String(bytes);
Image1.ImageUrl = String .Format( data:image / jpeg; base64,{0},imgString);




当我运行此代码时
。 .. image1出现空白



哪里有错误以及如何解决?



最好的问候



我的尝试:



-----

byte [] imagem =(byte [])x.Student_Picture;

string base64String = Convert.ToBase64String(imagem,0,imagem.Length);

images1.Src =data:image / jpeg; base64,+ base64String;

------------

解决方案

您好,请从这些链接获取帮助,



提前感谢



显示图像控件中的数据库中的图像,而不使用ASP.Net中的Generic Handler [ ^ ]



c# - 从asp.net中的数据库中检索图像 - Stack Overflow [ ^ ]

in my sql server db i have field name stuimage type image
i wanna display this image in asp:image id = "image1" in asp.net c#
using this code

byte[] bytes = (byte[])x.Student_Picture;
string imgString = Convert.ToBase64String(bytes);
Image1.ImageUrl = String.Format("data:image/jpeg;base64,{0}",imgString );



when i run this code ... image1 is appeared empty

where is the error and how to solve it ?

best regards

What I have tried:

-----
byte[] imagem = (byte[])x.Student_Picture;
string base64String = Convert.ToBase64String(imagem, 0, imagem.Length);
images1.Src = "data:image/jpeg;base64," + base64String;
------------

解决方案

Hi, take help from these links,

thanks in advance

Display image from database in Image control without using Generic Handler in ASP.Net[^]

c# - Retrieve image from database in asp.net - Stack Overflow[^]


这篇关于在ASP中显示图像:图像ASP.NET C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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