开发者

Accessing ActiveX method from asp.net (C#)

开发者 https://www.devze.com 2023-01-05 23:52 出处:网络
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 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 "cod开发者_开发技巧e 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;
    }


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号