473,484 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What is the purpose of CreateChildControls()?

Hi,

I'm coding a custom server control, and CreateChildControls() is giving me
some pain. I'm just wondering why we have CreateChildControls(), and why
this methods seems to be called at different times in the page lifecycle. I
mean the order it is called is not deterministic. Example if not post back,
then my CreateChildControls() is being executed before my Load event. But
for post back, my Load event executes before my CreateChildControls().

I suppose calling EnsureChildControls() will call CreateChildControls() if
it has not already been called. But why all this complication? I'm even
thinking about creating my controls in the constructor instead of inside
CreateChildControls(); at least this way I know that my controls will have
been created when I need to use them.
Jun 7 '06 #1
1 7032
Hi Michael,

Here's a good reference for this:

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

At the bottom, there is a note:

"The CreateChildControls method is not listed in the table because it is
called whenever the ASP.NET page framework needs to create the controls tree
and this method call is not limited to a specific phase in a control's
lifecycle. For example, CreateChildControls can be invoked when loading a
page, during data binding, or during rendering."

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.

"Michael" <mi*****@somewhere.com> wrote in message
news:Ou**************@TK2MSFTNGP05.phx.gbl...
Hi,

I'm coding a custom server control, and CreateChildControls() is giving me
some pain. I'm just wondering why we have CreateChildControls(), and why
this methods seems to be called at different times in the page lifecycle.
I mean the order it is called is not deterministic. Example if not post
back, then my CreateChildControls() is being executed before my Load
event. But for post back, my Load event executes before my
CreateChildControls().

I suppose calling EnsureChildControls() will call CreateChildControls() if
it has not already been called. But why all this complication? I'm even
thinking about creating my controls in the constructor instead of inside
CreateChildControls(); at least this way I know that my controls will have
been created when I need to use them.

Jun 8 '06 #2

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

Similar topics

14
2086
by: Mudge | last post by:
This thread is hereby dubbed PHP Purpose, or PHPP. It has the following purposes: 1. To bring together PHPers and programmers around the world to become organized. 2. To dicuss purposes of...
3
1826
by: yongbl | last post by:
Hi, I need to do a client-server project that involves TCP/IP and XML. I want to make it a meaningful project. My friends suggested doing a project on Web Service. What kind of web services...
24
7632
by: Hardy | last post by:
I'm pretty new in this field. when reading some 70x material, I met with this term but cannot catch its accurate meaning. who can help me? thanks in advance:)~
5
8163
by: rahul8143 | last post by:
hello, I want to know for what purpose union REGS and struct SREGS are used in windows programming? also how following code an determine that running OS is windows? in_regs.x.ax = 0x160A;...
6
6060
by: John Salerno | last post by:
I understand how they work (basically), but I think maybe the examples I'm reading are too elementary to really show their value. Here's one from Programming C#: #region Using directives ...
11
2516
by: z | last post by:
How can validation testing on DBMSs such as DB2 and Oracle be performed? Is there a quick commonly used publicly available DBMS test that can be used? Could TPC-C be used? If so, where can...
4
1866
by: Harro de Jong | last post by:
(absolute beginner here, sorry if this seems basic) Section 7.10 of 'How to Think Like a Computer Scientist' contains this discussion of string.find and other string functions: (quote) We can...
5
20885
by: vapour | last post by:
Hi, Quick question here, and wondering if anyone can help. I often see the hash character ('#') in regular expressions and am wondering what purpose it is supposed to serve. Example: ...
2
33675
by: Sam Bendayan | last post by:
Greetings, What is the point of Microsoft defining a ROWGUIDCOL property that can be attached to a 'uniqueidentifier' column? This is defined as a column that is 'globally unique', but doesn't...
0
7079
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
7103
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
7137
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
6809
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
7194
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...
0
5403
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
4838
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
4527
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...
1
587
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.