473,587 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4813
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******** ********@TK2MSF TNGP10.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
"CreateChildCon trols 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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ei******** *******@TK2MSFT NGP12.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******** ********@TK2MSF TNGP10.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
2164
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() when that event is 'going on' the load control happens but the values are not yet 'filled in' They are filled in only -when- the pageload event has
5
1294
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 the requiredfieldvalidator is ignored when using Netscape. The code logic is:
1
2044
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 able to grow & shrink according to the number of items in each quadrant. I have coded the table as a user control in vb.net. My question is on how to retrieve the data out of the table on a post back. I have tried adding check boxes as straight...
3
2633
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 CssClass to them, or programmatically making the Visible/not Visible. If applied to a containing page, such a function would traverse all user controls statically and dynamically placed on the page, correct? Thanks,
7
2998
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 attempting to bind a user control I've written, "ImageBox", to a repeater. The user control takes a custom property, "ContentID", that will execute a database lookup and load an image.
9
3613
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 to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I can't know what dynamic control I have to create.
4
4749
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 to demonstrate my issues. Lets say I have a WebForm with a DropDownList where the user selects a number from 1 to 10 (the DropDownList is not dynamically created). I also have a button on there that I use to trigger a PostBack. Based on the...
3
4356
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 number of dynamic controls that themselves have postback/autopostback so the display of the control needs to be built at latest in the Page.Load event or the event handlers for the controls don't get wired up. Now if I have a page that uses this user...
5
5017
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 not available at the moment I need them. Current problem: In a dynamically loaded ascx there is a dropdown. Based on the selected value (reloading an existing value or responding to a
0
7924
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8221
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5395
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.