asp.net中动态创建控件添加事件

来源:百度知道 编辑:UC知道 时间:2024/05/16 01:21:06
我在.net程序中,动态添加了一些ImageButton,请问我怎样为这些ImageButton添加单击事件

首先定义个事件函数:
protected void ImageButtonClick(object sender, EventArgs e)
{
//事件处理...
}
然后在创建ImageButton时,增加单击事件绑定:
ImageButton ibtn=new ImageButton();
...
ibtn.Click += new EventHandler(ImageButtonClick);
...