473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic controls & events

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
1 1988
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6796
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
1
7536
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
2
4217
by: Michael Ramey | last post by:
Howdy, I think I have a good question! I'm creating a usercontrol, and within this usercontrol, I'm dynamically creating controls (imagebuttons to be exact), that the user can click on which...
0
1097
by: Michael Ramey | last post by:
Hello, I'm trying to handle click events with button controls I've created dynamically. I've found two ways of dealing with them, neither of which I like, so I'm asking if anyone knows a better...
13
3647
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
3
3946
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
5
2388
by: mytestemailaccount | last post by:
Hi, Hope you can help. I am relatively new to all this but would appreciate the groups help. The scenario: I am c# and asp.net to create a web application. The web page contains a user...
2
2922
by: Ben Amada | last post by:
I'm a little confused about in what Event should I add dynamic controls and in what Event should I retrieve the value of a dynamic control on postback. I've found that adding dynamic controls in...
0
3466
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.