Problem with missing button clicks

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.
 
B

Bin Song

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
 
S

Suresh

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

Suresh.
 
J

John Smith Jr.

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.
 
J

John Smith Jr.

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"];
 
J

John Smith Jr.

Found out the problem here, I had to manually create the ID's of the
buttons, after that, problem disappeared.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top