Problem with missing button clicks

  • Thread starter Thread starter John Smith Jr.
  • Start date Start date
J

John Smith Jr.

I have a very strange problem, I am dynamically creating buttons and events,
when page loads the first click works fine, every click there after the
event only fires every other click.

I made a listbox, and showed when each method fires, and it shows First
Click: Page_load, Click Event, Next Click: Page_Load, Next Click:
Page_Load, Click Event.
 
It might be related to when you create the button and its
event. Click event will be raised after load event. If at
that time, the button is not created yet, the event will
not be raised.
Can you post your related code?

Bin Song, MCP
 
If you want server side event handling on controls that
were created dynamically then you have to wire the events
everytime you postback.

Suresh.
 
I am repopulating the table web control on postback. So they in fact should
be there.
But i am clearing table and recreating, is that what causing my problem
because the old id is gone and it creates another one?

I really don't know how to save out the table without repopulating it from
scratch.
 
Page_Load

Update Table


Update Table

Table.Rows.Clear
Array = Directory.GetDirectories(Session:MyCurrentDirectory);
Table.Rows.Add (dir name, blah blah, button: Enter Directory);

EnterDirectory Click Event

Session:MyCurrentDirectory = (button) sender.Attributes["dir"];
 
Found out the problem here, I had to manually create the ID's of the
buttons, after that, problem disappeared.
 
Back
Top