Posted on: 10/11/2013 4:29:48 PM | Views : 597

in Page_Load I have a dynamically created button which works fine. but when putting it in a subroutine it does not work. I do call the routine in page load so the control will be created each time.
works: protected void Page_Load(object sender, EventArgs e) {         Button btn = new Button();         btn.ID = "btnTst";         btn.Click += new EventHandler(btn_Click);         btn.Text = "OK";         Panel1.Controls.Add(btn); }
does not work:
protected void Page_Load(object sender, EventArgs e) {       tst(); }  protected void tst() {         Button btn = new Button();         btn.ID ...

Go to the complete details ...