All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Delphi其他查询
C#教程:线程的暂停与恢复
ASP.NET技巧:获取数据行数据信息_[Asp.Net教程]
SQL,Server存储过程编写和优化经验_[SQL,Server教程]
delphi限制鼠标移动的范围
从.NET类库代码来看ASP.NET运行时_.net资料_编程技术
C#网络应用编程基础练习题与答案(五)_[Asp.Net教程]
加速PHP动态网站,MySQL索引分析和优化_php资料_编程技术
PHP环境下配置在线编辑器FCKeditor_[PHP教程]
Cookie跨域、虚拟目录,,实现通行证登录_[Asp.Net教程]
Reading number is top 10 pictures
Hunan province aizhai super-large suspension bridge open to traffic and 4 world first1
我国房地产真相
[猫扑大杂烩]华东师范墙上看到的捐精告示 15毫升3600元
赵惟依写真1
农夫山泉变身记
徐若瑄展示美丽胸围2
中国女孩大胆自拍,显露完美身材4
寒流来了
无题
中国处女图鉴1
Download software ranking
双旗镇刀客A
Unix video tutorial15
Wild things 2
Tram sex maniac 2 (H) rar bag4
双旗镇刀客B
Boxer vs Yellow1
Unix video tutorial10
The Bermuda triangle3
Unix video tutorial1
C#与.NET技术平台实战演练
delv published in(发表于) 2014/1/23 3:13:07 Edit(编辑)
VS.Net,C#,调用,Active,组件_[Asp.Net教程]

VS.Net,C#,调用,Active,组件_[Asp.Net教程]

VS.Net C# 调用 Active 组件_[Asp.Net教程]

在编码中不可否认调用Active会给编程带来很大便利,虽然微软不太只持.net调用Active 组件。
本实例是一个简单Web 页面调用Active组件的例子,实现把数据传入并显示在active组件里的控件中。
  实例代码如下:
1、建立Active组件(这里用.net c#创建)
(本程序中:建立类库添加组件类后托放:label 、 button 、groupBox各一个)
   需要注意的是在生成.dll之前一定要在类库的AssemblyInfo.cs中加入引用using System.Security;和属性[assembly : AllowPartiallyTrustedCallers()],这是为了给控件赋予足够的权限使它能在页面上显示。


using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Windows.Forms ;


namespace ActiveXDotNet
{
/**////


/// AbeenControl 的摘要说明。
///

public class AbeenControl : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox1;
/**////
/// 必需的设计器变量。
///

private System.ComponentModel.Container components = null;


public string LabelText
{
get
{
return this.label1.Text.ToString();
}
set
{
this.label1.Text=value;
}
}


public AbeenControl(System.ComponentModel.IContainer container)
{
/**////
/// Windows.Forms 类撰写设计器支持所必需的
///
this.label1.Text="test";
container.Add(this);
InitializeComponent();


//
// TOD 在 InitializeComponent 调用后添加任何构造函数代码
//
}


public AbeenControl()
{
/**////
/// Windows.Forms 类撰写设计器支持所必需的
///
InitializeComponent();



//
// TOD 在 InitializeComponent 调用后添加任何构造函数代码
//
}


/**////


/// 清理所有正在使用的资源。
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}



组件设计器生成的代码#region 组件设计器生成的代码
/**////


/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///

private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(296, 23);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(120, 56);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(320, 88);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// AbeenControl
//
this.Controls.Add(this.groupBox1);
this.Name = "AbeenControl";
this.Size = new System.Drawing.Size(328, 96);
this.Load += new System.EventHandler(this.AbeenControl_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);


}
#endregion


private void button1_Click(object sender, System.EventArgs e)
{
this.label1.Text="点击完成!";
}


private void AbeenControl_Load(object sender, System.EventArgs e)
{


}
}
}
2、web 页面调用Active组件
  注意web页面调用时需要把Active的.dll放到web的虚拟要目录下。


TestActive







width="288" height="72" VIEWASTEXT>




onclick="doScript();" ID="Button1" NAME="Button1">











添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.