Display a generated gif;base64 image using C# code behind in img using JavaScript -


i have following c# code behind (it code generate dynamically bmp image , convert gif , returns displayed):

[webmethod] public static htmlimage processit() { var bitmap = drawingmethod(); //method draws dynamically bmp image  memorystream ms = new memorystream(); bitmap.save(ms, imageformat.jpeg); var base64data = convert.tobase64string(ms.toarray()); htmlimage img = new htmlimage  {src = "data:image/gif;base64," + base64data, width = 940}; return img; //the gif image want display on page } 

than, i'm calling c# behind code method : generate_onclick() javascript

function generate_onclick()  {   pagemethods.processit(onsucess, onerror);    function onsucess(result)      {      //here not sure how it's done !!!!!!      document.getelementbyid("imgctrl").src = result;      }     function onerror(result)      {       alert('something wrong.');     } } 

in here html code :

<img src="" alt="" style="width: 100%;" runat="server" id="imgctrl" /> 

is right way display image in page ? if not how ?

this untested believe should work. point here if want continue have want return base64 string , set source of html element string not html image object.

[webmethod] public static string processit() { var bitmap = drawingmethod(); //method draws dynamically bmp image  memorystream ms = new memorystream(); bitmap.save(ms, imageformat.jpeg); var base64data = convert.tobase64string(ms.toarray()); string img = "data:image/gif;base64," + base64data; return img; //the gif image want display on page } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -