473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dynamic Controls in User Control; page/control lifecycle question

I have a user control into which I insert a bunch of controls dynamically. I
have it all working just fine - Everything is there on Postback, etc.

I load this user control into a hosting ASPX page at runtime during the
Page_Load event procedure of the hosting ASPX page.

Question: Would it be better to load the user control from the hosting
page's OnInit event rather than Page_Load? Does it matter or not?

I ask because I understand that for dynamic controls to be properly
inserted - it must be done during the OnInit event - which is happening -
but only in the ASCX lifecycle (which gets kicked off from the hosting aspx
page_load).

Thanks.
Nov 19 '05 #1
2 4798
Hi Frankie,

The following >Net SDK article on Control Execution Lifecycle should clear
everything up for you. I keep a print-out of it on my office wall!

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Frankie" <A@B.COM> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a user control into which I insert a bunch of controls dynamically.
I have it all working just fine - Everything is there on Postback, etc.

I load this user control into a hosting ASPX page at runtime during the
Page_Load event procedure of the hosting ASPX page.

Question: Would it be better to load the user control from the hosting
page's OnInit event rather than Page_Load? Does it matter or not?

I ask because I understand that for dynamic controls to be properly
inserted - it must be done during the OnInit event - which is happening -
but only in the ASCX lifecycle (which gets kicked off from the hosting
aspx page_load).

Thanks.

Nov 19 '05 #2
Thanks Keven - great little article. Based on the following statements in
the article...

"a control is unable to invoke its parent until the tree of controls on a
page has been populated"
and
"CreateChildControls can be invoked when loading a page, during data
binding, or during rendering"

.... I'm concluding that the scenario I have created (as described in the OP)
is just fine - if not what must happen. If I'm totally wrong about that,
then please let me know - otherwise have a great day!

-Frankie

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ei***************@TK2MSFTNGP12.phx.gbl...
Hi Frankie,

The following >Net SDK article on Control Execution Lifecycle should clear
everything up for you. I keep a print-out of it on my office wall!

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Frankie" <A@B.COM> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a user control into which I insert a bunch of controls dynamically.
I have it all working just fine - Everything is there on Postback, etc.

I load this user control into a hosting ASPX page at runtime during the
Page_Load event procedure of the hosting ASPX page.

Question: Would it be better to load the user control from the hosting
page's OnInit event rather than Page_Load? Does it matter or not?

I ask because I understand that for dynamic controls to be properly
inserted - it must be done during the OnInit event - which is happening -
but only in the ASCX lifecycle (which gets kicked off from the hosting
aspx page_load).

Thanks.


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hi, I have a complex asp.net 1.1 program that dynamically needs to load controls (LoadControl) The textboxes etc inside these controls keep viewstate and values but not within Page_Load() ...
5
by: Steve Bugden | last post by:
Hello, I am trying to create a form dynamically. A very simple form with a textbox, requiredvalidator and button. Everything works fine on IE, but no server side validation occurs which means...
1
by: srneu71 | last post by:
I have a project that requires a dynamically generated matrix table. The table is setup with 4 quadrants (N,S,E,W) with checkboxes to "link" the data in adjacent quadrants. The table has to be...
3
by: Ken Fine | last post by:
I'm interested in programmatically manipulating groups of ASP.NET controls by type. Can someone suggest code for the following? Loop through, say, all label controls on a page, and assigning a...
7
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
3
balabaster
by: balabaster | last post by:
I've got a user control that builds a table of dynamic data based on a :LINQ class holding the data. The data is loaded using the LoadData(DataInstance) method. The table it builds contains a...
5
by: Hans Kesting | last post by:
Hi, Is there good information about the asp.net page lifecycle in combination with dynamically loaded controls? Or on "how to build dynamic controls"? I keep hitting problems where values are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.