ASP.net组件编程中的两种事件编写方法
来源:互联网 发布:歌曲修改软件 编辑:程序博客网 时间:2024/05/16 11:23
以下是组件代码:
usingSystem; usingSystem.Web.UI; usingSystem.Web.UI.WebControls; usingSystem.ComponentModel; namespaceNSEventStudy { publicdelegatevoidTwoEventHandle(intflag); publicclassEventStudy:System.Web.UI.WebControls.WebControl { ///////////////第一种定义事件的方法//////////////////// publiceventTwoEventHandleTwoEvent; publicvoidExecute(intflag) { TwoEvent(flag); } ////////////////第二种定义事件的方法//////////////////// privatestaticobject_Process=newobject(); publiceventTwoEventHandleThreeEvent { add { Events.AddHandler(_Process,value); } remove { Events.RemoveHandler(_Process,value); } } publicvoidInnerExecute(intflag) { TwoEventHandlehandle=(TwoEventHandle)Events[_Process]; if(handle!=null) { handle(flag); } else { this.RaiseBubbleEvent(this,null); } } protectedoverridevoidRender(HtmlTextWriterwriter) { base.Render(writer); writer.WriteLine("我爱你,中国"); } } } |
测试程序:
usingSystem; usingSystem.Collections; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Web; usingSystem.Web.SessionState; usingSystem.Web.UI; usingSystem.Web.UI.WebControls; usingSystem.Web.UI.HtmlControls; namespaceTestEvent { ///<summary> ///WebForm1的摘要说明。 ///</summary> publicclassWebForm1:System.Web.UI.Page { protectedSystem.Web.UI.WebControls.ButtonButton1; protectedNSEventStudy.EventStudyEventStudy1; privatevoidPage_Load(objectsender,System.EventArgse) { //在此处放置用户代码以初始化页面 } #regionWeb窗体设计器生成的代码 overrideprotectedvoidOnInit(EventArgse) { // //CODEGEN:该调用是ASP.NETWeb窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } ///<summary> ///设计器支持所需的方法-不要使用代码编辑器修改 ///此方法的内容。 ///</summary> privatevoidInitializeComponent() { this.EventStudy1.ThreeEvent+=newNSEventStudy.TwoEventHandle(this.EventStudy1_ThreeEvent); this.EventStudy1.TwoEvent+=newNSEventStudy.TwoEventHandle(this.EventStudy1_TwoEvent); this.Button1.Click+=newSystem.EventHandler(this.Button1_Click); this.Load+=newSystem.EventHandler(this.Page_Load); } #endregion privatevoidEventStudy1_TwoEvent(intflag) { this.Response.Write("<script>javascript:alert('TwoEvent事件触发')</script>"); } privatevoidEventStudy1_ThreeEvent(intflag) { this.Response.Write("<script>javascript:alert('ThreeEvent事件触发')</script>"); } privatevoidButton1_Click(objectsender,System.EventArgse) { this.EventStudy1.Execute(6); this.EventStudy1.InnerExecute(10); } } } |
- ASP.net组件编程中的两种事件编写方法
- ASP.net组件编程中的两种事件编写方法
- ASP.net组件编程中的两种事件编写方法
- ASP.net组件编程中的两种事件编写方法
- ASP.net组件编程中的两种事件编写方法
- ASP.net组件编程中的两种事件编写方法
- ASP.net组件编程中的两种事件编写方法
- 注册ASP组件的两种方法
- ASP.NET组件编程
- C#编写ASP.NET组件...
- WinForm中的ListBox组件编程(asp.net) _转载
- 将ASP.net中的Table中的数据导入到Execl的两种方法
- asp.net 连接MySql两种方法
- 编写asp.net页面的两种方式
- ASP调用.NET编写的组件
- Asp.net防注入组件的编写
- .net中的两种计时方法
- ASP.NET中的事件处理
- Login控件:用户登录失败的消息提示
- 爱国者首款手机正式上市 零售价不超2000元
- 在ADO.NET中用参数化查询缩短开发时间
- 使用Struts开发Web应用常见的一些问题汇总
- Google解密携手宏达电:确保Android一炮打响
- ASP.net组件编程中的两种事件编写方法
- 《福布斯》:微软的印度未来
- WMS(JBuilder+oracle)系统移植问题及解决过程
- Postcard:简单的音乐贺卡制作
- Oracle spfile example
- 百度声明:从未答应屏蔽三鹿负面
- 抚顺小吃之旅-http://bbs.fushun.cc(转自抚顺论坛)
- 本周Web2.0小工具推荐[2008-09-13]
- 汇编指令: 根据www.olanguage.org提供的汇编资料整理. 转自万一