Accessing ActiveX method from asp.net (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.
精彩评论