从 asp.net 访问 ActiveX 方法 (C#)
我编写了一个 activex 用户控件来从用户的剪贴板获取图像。我有一种方法来获取该图像的字节流。我想将其嵌入到 asp.net webforms 页面(C#)中。
我不确定如何使用 c# 从 asp.net 页面的“代码隐藏”部分调用此方法。我无法从“代码隐藏”部分访问该对象。
我试图通过使用 Javascript 来完成此操作,但我不断收到错误:
Microsoft JScript 运行时错误:'ScreenCapMod1' 未定义
这是 HTML 代码:
<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();">
函数 doScript() { ScreenCapMod1.getScreenshot(); }
这是获取屏幕截图方法的代码:
public byte[] getScreenshot()
{
if (picBoxImagePrev.Image != null)
{
MemoryStream stream = new MemoryStream();
scaledScreenCapture.Save(stream, ImageFormat.Png);
imgStream = stream.ToArray();
}
return imgStream;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ActiveX 控件将在客户端运行,因此您需要某种方法将数据从客户端推送到服务器。标准 Web 服务应该可以为您完成此任务。
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.