Click here to Skip to main content
14,301,066 members
Rate this:
Please Sign up or sign in to vote.
See more:
I want to display an image from SQL server to my web page.
Iam following Layered architecture, I got the image on my presentation layer(ASPX.Cs)
like {byte[6317]}

How to convert it into an image on my webpage
Posted
Comments
ZurdoDev 26-Sep-14 7:32am
   
There are lots of samples online. Where are you stuck?
MAGuru 26-Sep-14 8:02am
   
please give me a link
ZurdoDev 26-Sep-14 8:14am
   
google.com

Serious. Just do a little bit of work on your own first. You'll learn more that way.
sankarsan parida 26-Sep-14 7:34am
   
use image hander file for this
Rate this:
Please Sign up or sign in to vote.

Solution 1

Refer -
Display Byte Array as Image without using Generic Handler in ASP.Net
[^].

Very simple...
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
Image1.ImageUrl = "data:image/png;base64," + base64String;
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi,

Check the follow link to display image without using generic handler :

http://www.aspsnippets.com/Articles/Display-image-from-database-in-Image-control-without-using-Generic-Handler-in-ASPNet.aspx[^]

Or you can achieve this by using generic handler :

Generic Image Handler Using IHttpHandler[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Thanks a lot for your answers. I appreciate you all. But my problem is the picture is in an asp image control.

i am not using the file uploader. i am saving the image in an image control to database.

That is my problem.

Thanks.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100