成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

ASP.NET組件編程之事件編寫淺析

開發 后端
ASP.NET組件編程中事件編寫的方法是什么呢?本問就向你介紹兩種ASP.NET組件編程的事件編寫方法。

ASP.NET組件編程之事件編寫是如何的呢?那么我們首先來看看ASP.NET組件的應用:

ASP.NET組件編程之組件代碼:

  1. using System;   
  2. using System.Web.UI;   
  3. using System.Web.UI.WebControls;   
  4. using System.ComponentModel;   
  5.  
  6. namespace NSEventStudy   
  7. {   
  8. public delegate void TwoEventHandle(int flag);   
  9.  
  10. public class EventStudy : System.Web.UI.WebControls.WebControl   
  11. {   
  12.  
  13. ///////////////ASP.NET組件編程***種定義事件的方法////////////////////   
  14.  
  15. public event TwoEventHandle TwoEvent;   
  16.  
  17. public void Execute(int flag)   
  18. {   
  19. TwoEvent(flag);   
  20. }   
  21.  
  22. ////////////////ASP.NET組件編程第二種定義事件的方法////////////////////   
  23.  
  24. private static object _Process = new object();   
  25. public event TwoEventHandle ThreeEvent   
  26. {   
  27. add   
  28. {   
  29. Events.AddHandler(_Process,value);   
  30. }   
  31. remove   
  32. {   
  33. Events.RemoveHandler(_Process,value);   
  34. }   
  35. }   
  36.  
  37. public void InnerExecute(int flag)   
  38. {   
  39. TwoEventHandle handle = (TwoEventHandle)Events[_Process];   
  40. if(handle != null)   
  41. {   
  42. handle(flag);   
  43. }   
  44. else   
  45. {   
  46. this.RaiseBubbleEvent(this,null);   
  47. }   
  48. }   
  49.  
  50. protected override void Render(HtmlTextWriter writer)   
  51. {   
  52. base.Render (writer);   
  53. writer.WriteLine("我愛你,中國");   
  54. }   
  55.  
  56. }   
  57. }  

ASP.NET組件編程之事件實現測試程序:

  1. using System;   
  2. using System.Collections;   
  3. using System.ComponentModel;   
  4. using System.Data;   
  5. using System.Drawing;   
  6. using System.Web;   
  7. using System.Web.SessionState;   
  8. using System.Web.UI;   
  9. using System.Web.UI.WebControls;   
  10. using System.Web.UI.HtmlControls;   
  11.  
  12. namespace TestEvent   
  13. {   
  14. /// ﹤summary﹥   
  15. /// WebForm1 的摘要說明。   
  16. /// ﹤/summary﹥   
  17. public class WebForm1 : System.Web.UI.Page   
  18. {   
  19. protected System.Web.UI.WebControls.Button Button1;   
  20. protected NSEventStudy.EventStudy EventStudy1;   
  21.  
  22. private void Page_Load(object sender, System.EventArgs e)   
  23. {   
  24. // 在此處放置用戶代碼以初始化頁面   
  25. }   
  26.  
  27. #region Web 窗體設計器生成的代碼   
  28. override protected void OnInit(EventArgs e)   
  29. {   
  30. //   
  31. // CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。   
  32. //   
  33. InitializeComponent();   
  34. base.OnInit(e);   
  35. }   
  36.  
  37. /// ﹤summary﹥   
  38. /// 設計器支持所需的方法 - 不要使用代碼編輯器修改   
  39. /// 此方法的內容。   
  40. /// ﹤/summary﹥   
  41. private void InitializeComponent()   
  42. {   
  43. this.EventStudy1.ThreeEvent += new NSEventStudy.TwoEventHandle(this.EventStudy1_ThreeEvent);   
  44. this.EventStudy1.TwoEvent += new NSEventStudy.TwoEventHandle(this.EventStudy1_TwoEvent);   
  45. this.Button1.Click += new System.EventHandler(this.Button1_Click);   
  46. this.Load += new System.EventHandler(this.Page_Load);   
  47.  
  48. }   
  49. #endregion   
  50.  
  51. private void EventStudy1_TwoEvent(int flag)   
  52. {   
  53. this.Response.Write("﹤script﹥javascript:alert('TwoEvent事件觸發')﹤/script﹥");   
  54. }   
  55.  
  56. private void EventStudy1_ThreeEvent(int flag)   
  57. {   
  58. this.Response.Write("﹤script﹥javascript:alert('ThreeEvent事件觸發')﹤/script﹥");   
  59. }   
  60.  
  61. private void Button1_Click(object sender, System.EventArgs e)   
  62. {   
  63. this.EventStudy1.Execute(6);   
  64. this.EventStudy1.InnerExecute(10);   
  65. }   
  66. }   

ASP.NET組件編程中事件的編寫實現就向你介紹到這里,希望對你有所幫助。

【編輯推薦】

  1. ASP.NET服務器控件視圖淺析
  2. ASP.NET組件設計之生命周期詳解
  3. ASP.NET組件設計之傳輸機制淺析
  4. ASP.NET組件設計之復雜屬性和狀態管理淺析
  5. ASP.NET httpHandler使用淺析
責任編輯:仲衡 來源: 教程在線
相關推薦

2009-08-06 13:08:23

ASP.NET控件開發

2009-08-10 16:07:44

ASP.NET Lin

2009-08-10 15:42:33

ASP.NET Che

2009-08-05 16:53:14

ASP.NET組件設計

2009-07-24 18:02:46

ASP.NET編程

2009-08-10 13:32:15

ASP.NET TimASP.NET組件設計

2009-07-27 14:29:31

ASP.NET編程彈窗報警提示

2009-09-09 12:35:00

ASP.NET回車提交回車提交事件

2009-08-03 13:38:18

ASP.NET編程模型

2009-08-05 16:59:55

ASP.NET組件設計

2009-07-22 17:45:35

ASP.NET教程

2009-08-03 13:12:34

ASP.NET編程模型

2009-07-27 13:34:15

ASP.NET編程

2009-08-05 18:36:12

ASP.NET Che

2009-07-24 13:41:15

ASP.NET AJA

2009-07-31 12:43:59

ASP.NET MVC

2009-08-05 15:50:13

ASP.NET優點

2009-08-10 14:38:29

ASP.NET組件設計

2009-08-03 11:21:47

ASP.NET編程模型

2009-08-03 18:00:00

ASP.NET服務器控
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 中文字幕一区二区三区在线观看 | 米奇狠狠鲁 | 农夫在线精品视频免费观看 | 精品国产鲁一鲁一区二区张丽 | 91 视频网站 | 91久久国产综合久久 | 五月天婷婷综合 | 日韩欧美在线一区二区 | 日韩成人在线免费视频 | 久久久www成人免费无遮挡大片 | 免费网站国产 | 91久久久久久久久久久久久 | 欧美久久久网站 | 成人精品鲁一区一区二区 | 久久久999国产精品 中文字幕在线精品 | 久久亚洲一区二区三区四区 | 国产激情一区二区三区 | 欧美一区不卡 | 欧美日韩18 | 伊人久久大香线 | 日韩欧美在线一区二区 | 亚洲一区二区三区四区五区午夜 | 国产在线观看一区 | 日本天天色 | 国产区第一页 | www网站在线观看 | 久久综合成人精品亚洲另类欧美 | 日韩精品一区二区三区中文字幕 | 91tv在线观看 | 久久久精品视频一区二区三区 | 日韩精品免费视频 | 国产精品日韩在线观看一区二区 | 性国产xxxx乳高跟 | 国产乱码精品一区二区三区忘忧草 | 国产成人精品久久二区二区 | 久久亚洲国产精品日日av夜夜 | 欧美久久久久久久久中文字幕 | 羞羞网站在线观看 | 成人超碰在线 | 2021天天躁夜夜看 | 欧美视频在线免费 |