自定义控件添加事件

protected void Page_Load(object sender, EventArgs e)//夫页面的函数
        {
             ctrl.BackEvent += delegate(object s, EventArgs ea)
            {       
                DO();
            };

             }

控件内部定义
 public event EventHandler BackEvent;

 protected void btnCancel_Click(object sender, EventArgs e)
        {
            if (BackEvent != null)
                BackEvent(this, EventArgs.Empty);//调用事件
        }

当控件调用btnCancel_Click时同时也会执行do
posted @ 2007-07-27 16:28  ahuo  阅读(610)  评论(0编辑  收藏  举报