Event Handler Not Called.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a WebControl.Table on my WebForm. In the Table I have LinkButtons.
I inserted and created these link buttons dynamically. Please Look at the
Code below.

LinkButton lb = new LinkButton();
lb.Text = "Details";
lb.Click += new System.EventHandler(this.LinkButton_Click);
Table1.Rows.Cells[2].Controls.A(lb);

Now when I click on the Link Button the Page does a post back but the
LinkButton_Click function is not called.

In fact, I tried adding a regular button to the table statically and then
tried clicking on the button but the appropriate handler is not called. The
Page does do a post back but the handler is not called. Can some one tell me
why? and How do I fix it?

Shreyash.
 
Are you recreating the LinkButton control on postback also? If not, the
Click event handler will not be called on postback.

message Hi,
I have a WebControl.Table on my WebForm. In the Table I have LinkButtons.
I inserted and created these link buttons dynamically. Please Look at the
Code below.

LinkButton lb = new LinkButton();
lb.Text = "Details";
lb.Click += new System.EventHandler(this.LinkButton_Click);
Table1.Rows.Cells[2].Controls.A(lb);

Now when I click on the Link Button the Page does a post back but the
LinkButton_Click function is not called.

In fact, I tried adding a regular button to the table statically and then
tried clicking on the button but the appropriate handler is not called. The
Page does do a post back but the handler is not called. Can some one tell me
why? and How do I fix it?

Shreyash.
 
Back
Top