views:

36

answers:

1

I have written an activex user control to get an image from a user's clipboard. I have a method to get the byte stream for this image. I want to embed this into a asp.net webforms page (C#).

I am not sure how to call this method from the "code behind" portion of the asp.net page by using c#. I am not able to access the object from the "code behind" portion.

I am trying to accompish this by using Javascript but I keep getting the error:

Microsoft JScript runtime error: 'ScreenCapMod1' is undefined

This is the HTML code:

    <div id="panelScn" style="height:258px;">

        <object id="ScreenCapMod1" name="ScreenCapMod1" height="812" width="689"
            classid="ScreencaptureActiveX.dll#Screencapture_ActiveX.ScreenCapModule">
        </object>
     <input type=button value="Click me" onClick="doScript();">

function doScript() { ScreenCapMod1.getScreenshot(); }

This is the code for the get screenshot method:

    public byte[] getScreenshot()
    {
        if (picBoxImagePrev.Image != null)
        {
            MemoryStream stream = new MemoryStream();
            scaledScreenCapture.Save(stream, ImageFormat.Png);
            imgStream = stream.ToArray();
        }
        return imgStream;
    }
+1  A: 

The ActiveX control will run on the client side, so you need some way of pushing that data from the client to the server. A standard web service should accomplish this for you.

Matthew Abbott