protected void Page_Load(object sender, EventArgs e)
{
Button btnTest = new Button();
btnTest.Text = "动态添加控件";
this.PanTest.Controls.Add(btnTest);
btnTest.Command += new CommandEventHandler(this.On_Button);
}
protected void On_Button(Object sender, CommandEventArgs e)
{
Response.Write("<script language = 'javascript' type = 'text/javascript'>alert('动态添加控件成功!');</script>");
}
楼上niuX……