zoukankan      html  css  js  c++  java
  • IPostBackEventHandler 事件实现

     1  [DefaultProperty("Text")]
     2     [ToolboxData("<{0}:HBButton2 runat=server></{0}:HBButton2>")]
     3     public class HBButton2: Control, IPostBackEventHandler
     4     {
     5         // 声明Click事件委托
     6         private static readonly object ClickKey = new object();
     7 
     8         public event EventHandler Click
     9         {
    10             add
    11             {
    12                 Events.AddHandler(ClickKey, value);
    13             }
    14             remove
    15             {
    16                 Events.RemoveHandler(ClickKey, value);
    17             }
    18         }
    19 
    20         // 定义OnClick事件处理程序
    21         protected virtual void OnClick(EventArgs e)
    22         {
    23             EventHandler clickEventDelegate =
    24                (EventHandler)Events[ClickKey];
    25             if (clickEventDelegate != null)
    26             {
    27                 clickEventDelegate(this, e);
    28             }
    29         }
    30 
    31         // 实现RaisePostBackEvent方法,处理回发事件
    32         public void RaisePostBackEvent(string eventArgument)
    33         {
    34             OnClick(new EventArgs());
    35         }
    36 
    37         protected override void Render(HtmlTextWriter output)
    38         {
    39             output.Write("<INPUT TYPE=submit name=" + this.UniqueID +
    40                " Value='确定' />");
    41         }
    42 
    43     }

  • 相关阅读:
    Qt 资料大全
    Node.js+websocket+mongodb实现即时聊天室
    win系统下nodejs安装及环境配置
    nginx关于 error_page指令详解.md
    移动前端开发之viewport,devicePixelRatio的深入理解
    Iphone各个型号机型的详细参数,尺寸和dpr以及像素
    H5前端的关于像素解释
    从Pc转向H5开发遇到的适配问题思考
    Safari无痕模式下,storage被禁用问题
    滴滴开源 Vue 组件库— cube-ui
  • 原文地址:https://www.cnblogs.com/HeroBeast/p/757232.html
Copyright © 2011-2022 走看看