By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,186 Members | 1,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,186 IT Pros & Developers. It's quick & easy.

Dynamic controls & events

P: n/a
I have problems in understanding the behavior of the events triggered by
dynamically created controls over a webform.
Could you help me?

In a webform, I have a static PlaceHolder PH containing a table of
controls, dynamically generated. Among these, a linkbutton (LinkBtn) to
which have attached a click handler method, LinkBtn_Click(...) .
Generally it works fine, but if in the LinkBtn_Click(...) code I try to
access a webform control, even the static PlaceHolder PH, I have a runtime
message saying that the control does not exist in the page.

Nevertheless, I have put the procedure that creates the dynamic table of
controls in the Page_Load, and from the debugger I see that this method is
called before entering the dynamic linkbutton click handler LinkBtn_Click .
Until the last instruction of the Page_Load, all the static and dynamic
controls have been created and added to the page & placeholder (I see them
in the debugger Watch window). As the code enter, as the immediately next
step, the LinkBtn_Click lines, all the Page controls disappear (the
Page.Controls.Count is zero ).
Why?
On the same webform I have also some static Button(s) and when entering
their click handler, all works fine, the table is dynamically geneterated in
the correct way and I can access the dynamic controls.

Davide
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
It sounds like you are doing it correctly. Do you want to post a code
sample to look at?

bill

"hybrid" <in**@hybrid.it> wrote in message
news:2e***********************@news2.tin.it...
I have problems in understanding the behavior of the events triggered by
dynamically created controls over a webform.
Could you help me?

In a webform, I have a static PlaceHolder PH containing a table of
controls, dynamically generated. Among these, a linkbutton (LinkBtn) to
which have attached a click handler method, LinkBtn_Click(...) .
Generally it works fine, but if in the LinkBtn_Click(...) code I try to
access a webform control, even the static PlaceHolder PH, I have a runtime
message saying that the control does not exist in the page.

Nevertheless, I have put the procedure that creates the dynamic table of
controls in the Page_Load, and from the debugger I see that this method is
called before entering the dynamic linkbutton click handler LinkBtn_Click .. Until the last instruction of the Page_Load, all the static and dynamic
controls have been created and added to the page & placeholder (I see them
in the debugger Watch window). As the code enter, as the immediately next
step, the LinkBtn_Click lines, all the Page controls disappear (the
Page.Controls.Count is zero ).
Why?
On the same webform I have also some static Button(s) and when entering
their click handler, all works fine, the table is dynamically geneterated in the correct way and I can access the dynamic controls.

Davide

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.