See ThatButton btn=new Button();
btn.Text="Button";
btn.Click += new System.EventHandler(this.btn_Click);
this.Controls[1].Controls.Add(btn);void btn_Click(object sender, System.EventArgs e)
{
Response.Write("hgknight");
}
btn.Text="Button";
btn.Click += new System.EventHandler(this.btn_Click);
this.Controls[1].Controls.Add(btn);void btn_Click(object sender, System.EventArgs e)
{
Response.Write("hgknight");
}
http://expert.csdn.net/Expert/topic/1118/1118663.xml?temp=.6648218有任何问题请与dillon联系:)
for(int i=0;i<5;i++)
{
Button btn=new Button();
btn.Text="Button";
//5个按钮要5个事件,可不可能???
btn.Click += new System.EventHandler(this.btn_Click);
Controls.Add(btn);
}
{
Button btn=new Button();
btn.Text="Button";
btn.Click += ehl[i];
Controls.Add(btn);
}note, to trigger the event handlers, you need to create those buttons before-hand, preferably in Page_Init or Page_Load
你是要对每个button都进行不同的处理还是怎么的?
你的所有处理都可以在
private void btn_click(..)
中处理如果你使用楼上的方法。
如果你只想对一类事件处理,你可以用选择用btn的id号来区分了。
结贴了,来者有分。