环境:asp.net2.0 c#,动态生成服务器端按钮并附与事件,为什么运行时事件没有触发?
代码如下: 请各位达人帮帮助
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
LoadControl();
}
}
private void LoadControl()
{
Button b = new Button();
b.Click += new EventHandler(b_Click);
b.Text = "单击";
aaa.Controls.Add(b);
}
void b_Click(object sender, EventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}