自定义控件添加事件
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
{
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