Michal Krawiec
Michal Krawiec

Reputation: 375

Showing image with javascript

I am trying to display image, which is dynamically generated on client side with Silverlight, in a new browser window. This is my javascript function:

function PrintImage(img) 
    {            
        var newWin = window.open();
        var locImg = new Image();

        locImg = img;

        newWin.document.write("<img src=" + locImg + "/>");          
    }

img var is a parameter of c# type BitmapImage. Unfortunately I am newbie with javascript. Thanks for replies.

Upvotes: 0

Views: 236

Answers (2)

Akash Kava
Akash Kava

Reputation: 39916

You can not do that, the only and best option available is display your image in Silverlight Application itself.

Javascript runs on browser, it can not access bitmap images which are CLR/.NET objects.

In case if you want to show it on new window, its better you create a new window, load silverlight application in new window ( a different one) and then create image and display it there.

You can not easily pass objects from one silverlight app to another silverlight app on same browser, however I have not experimented but it may not work correctly.

Upvotes: 1

rahul
rahul

Reputation: 187030

The best way you can do is to save the dynamically generated image in a folder in server and get the path of the image.

Pass the image path[string] to the function.

Upvotes: 0

Related Questions