For my new asp.net application that I am developing I would like to generate an image at runtime using a webservice (return bytes), and show this as a image using Javascript (so that I can have ajax functionality.
Any ideas how to do this?
Or any ideas as to how I can generate an image at runtime, and show it on my webpage using Ajax (must not postback), without having to save the image to any location on the hard drive?
Thanks!
Instead of having the web service put an ASHX page with the querystring parameters handling the input params. Make sure the Response.Content type is image/png
This ASHX page will generates the image stream on the fly and send it to the requesting image object. With this there is no image file saved on the server.
Here is a links with full code for the ASHX .
After you have done this, in JavaScript access the image object via DOM and set/change the SRC property.
function ChangeImage(param1, param2)
{
var url = "http://someserver/somepage.ashx?param1=" + param1 + "¶m2=" + param2;
var image1 = document.getElementById("MyImage");
image1.src = url;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With