Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to display an image (byte array) using purely JavaScript.

How can I achieve this in ASP?

share|improve this question
javacript and image data are two different thinks, meaning that you can display image with base64 data, but the javascript not needed - you only needed if you try to manipulate the page. What are you have up to now, and what actually try to gain here ? Do you have any javascript code to show us for what you try to do ? – Aristos Feb 27 '12 at 11:14
you can see: stackoverflow.com/questions/4564119/… – shmoltz Feb 27 '12 at 11:23

1 Answer

up vote 6 down vote accepted

If you have the byte array first you convert it to Base64String and then you place it on an img tag like that (for png image)

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">

Similar Questions:

How to display an Image stored in bytes on a page

Problem with 'data:image/jpg;base64' and jQuery image preview in IE

convert from Binarydata to image control in asp.net

share|improve this answer
1  
thanks Aristos :) – Bonus Kun Feb 27 '12 at 13:14
and what about explorer 7? – Eric Frick Mar 15 at 17:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.