.net ActiveX 对象
我正在尝试将我的 .net 图像编辑器用户控件用作 Web 表单中的 activeX 对象。
经过互联网搜索,我从VS2008创建了一个asp.net网站并添加了以下代码
<object classid="res/ImageEditor.dll#ImageEditor.Editor"
height="400" width="400" id="myControl1" name="myControl1" >
</object>
<INPUT id="Button1" type="button" value="Btn" name="Btn" onclick="return Button1_onclick()">
</script>
<script language=javascript>
function Button1_onclick() {
alert(document.getElementById("myControl1").WatermarkText);
}
</script>
我有两个问题
1-)当我第一次创建项目时我在浏览器上看到用户控件,但是在重建用户控件并更改dll之后文件在网站上时,该对象不再出现在浏览器上。相反,我看到类似错误图像的东西。
2-) 我无法访问公共属性。
用户控件被标记为“使 com 可见”,并在属性中检查 com 的注册。
I am trying to use my .net image editor user control as an activeX object in a web form.
After internet search, I created a asp.net web site from VS2008 and added the following code
<object classid="res/ImageEditor.dll#ImageEditor.Editor"
height="400" width="400" id="myControl1" name="myControl1" >
</object>
<INPUT id="Button1" type="button" value="Btn" name="Btn" onclick="return Button1_onclick()">
</script>
<script language=javascript>
function Button1_onclick() {
alert(document.getElementById("myControl1").WatermarkText);
}
</script>
I have two problems
1-) When i first create the project i see the user control on browser but, after rebuilding the user control and changing the dll file at web site, the object no more appears on browser. Instead i see something like an error image.
2-) i can not access public properties.
The user control is marked as "make com visible", and register for com is checked at properties.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使 .NET UserControl 能够像 ActiveX 一样良好地运行,需要克服很多困难。
请参阅我对上一个问题的回答,了解如何让它发挥作用。
为了更清楚地说明为什么您在构建 UserControl 时遇到问题,您可能已经在项目属性中添加了自动构建号。 “硬编码”属性中的版本号。只要不改变界面就应该没问题。
注意:您必须实现公共 IDispatch 接口才能访问您的属性。
There are quite a few hoops to jump through in order to get a .NET UserControl to behave nicely as an ActiveX.
See my answer to this previous question, on how to get it working.
To add more clarity on why you're having problems with building your UserControl, you've probably got the auto build number going in your project properties. "Hard code" the version number in the properties. As long as you don't change interface you should be fine.
N.B. You have to implement a public IDispatch interface for your properties to be accessable.