- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个带有 ActiveX 界面的 .NET 用户控件。它运作良好。
现在,我希望能够从 ActiveX 接口(interface)的属性包中读取和写入。
我该怎么做?
最佳答案
最简单的方法是使用客户端脚本将参数值传递给 ActiveX
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script language="javascript">
function Rundata(file)
{
var winCtrl = document.getElementById("YourActiveX");
winCtrl.Option1 = file;
winCtrl.WriteToFile();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<object id="YourActiveX" classid="clsid:6b1bdf22-1c1d-774e-cd9d-1d1aaf7fd88f"
width="300px" height="200px">
<param name="Option1" value="valuetoRetrieve1" />
</object>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button runat="server" ID="Button1" OnClientClick="javascript:Rundata('valuetoRetrieve2');" />
</div>
</form>
</body>
</html>
<object id="YourActiveX" classid="clsid:6b1bdf22-1c1d-774e-cd9d-1d1aaf7fd88f"
width="300px" height="200px">
<param name="option1" value="valuetoRetrieve" />
</object>
[ComImport]
[Guid("55272A00-42CB-11CE-8135-00AA004BB851")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPropertyBag
{
void Write([InAttribute] string propName, [InAttribute] ref Object ptrVar);
void Read([InAttribute] string propName, out Object ptrVar, int errorLog);
}
[ComImport]
[Guid("37D84F60-42CB-11CE-8135-00AA004BB851")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPersistPropertyBag
{
[PreserveSig]
void InitNew();
[PreserveSig]
void Load(IPropertyBag propertyBag, int errorLog);
[PreserveSig]
void Save(IPropertyBag propertyBag, [InAttribute] bool clearDirty, [InAttribute] bool saveAllProperties);
[PreserveSig]
void GetClassID(out Guid classID);
}
void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog)
{
object value;
propertyBag.Read("option1", out value, errorLog);
string parameter = (string)value;
}
关于interop - 在 C# 中使用 ActiveX PropertyBags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/421857/
我的应用程序是在 C# 下构建的,需要动态属性处理。该动态属性由最终用户处理,在我的每个业务对象中添加和删除新字段。 因此,我的方法是在每个对象上构建一个 PropertyBag,例如: public
按以下方式使用 Chrome 调试器: console.dir(element); 在控制台上,数据类型称为“PropertyBag”。我会期待“对象”。 什么特殊的对象是“PropertyBag”?
我创建了一个带有 ActiveX 界面的 .NET 用户控件。它运作良好。 现在,我希望能够从 ActiveX 接口(interface)的属性包中读取和写入。 我该怎么做? 最佳答案 最简单的方法是
我有这个自定义属性 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class TestServer : P
我有一个遗留系统,我正在从 VB 6 移植到 C#,我正处于从 Access 中的旧应用程序数据库中获取数据并将其移植到 Sql Server 中的新数据库的阶段。 access数据库中有几个字段是字
我使用 this tutorial 在 SharePoint 2010 (basicHttpBinding) 中托管了一个 WCF 服务.程序集部署到 GAC 并包含 WCF 服务和计时器作业。两者调
我是一名优秀的程序员,十分优秀!