473,507 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repost, please help, my composite control's oninit won't fire

I hate to repost a message, but I am still at the same point where I
was when I originally posted, and hopefully someone else will see this
one...

Ok, so I have gone off and documented the lifecycle of a page with a
custom composite control on it. You can find that document here:
http://www.ats-engineers.com/lifecycle.htm
Now, I am working on a much more complex grid example, and according to

my findings, the order should be like so:
Page Constructor
Page OnInit
Page OnLoad Enter
Page Instantiates Composite Control
Control Constructor Enter
Control Adds Button
Control Constructor Exit
Control OnInit
Page OnLoad Exit
Control OnLoad
Page PreRender
Page SaveViewState
Control SaveViewState
Control OnUnLoad
Page OnUnLoad
The document I linked to above shows the code that I used to produce
this output, and I have stepped through it multiple times to verify
that this order is true.
Now my problem is that in my MUCH more complex Custom Control, I watch
the code go from the controls constructor, to the pages OnPreRender
method, skipping the controls oninit and onload methods (which will
skip the LoadViewState method if it is a postback). There has gotta be
something simple wrong with my other composite control. However that
control is about 700 lines of code, and I don't expect anyone to go
through it, especially considering that it uses about 10 other custom
classes that I wrote.
So without me getting into too much detai, the question is what could
cause a controls oninit to not fire. This composite control inherits
from PlaceHolder, just like the example I site in my page I referred to

above, so that shouldn't be the problem. The control is being added to
the page just as in the above example as well. However, I am trying to
get it to load the view state, and those methods are never called
either, it's like it isn't a System.Web.Control at all...
Any ideas?

Andy Baldwin

Jun 2 '06 #1
3 2984
control onint does not always fire on page init. it will only be included if
it exits at page init time. if you create your child controls at prerender,
then the child controls onint fires during prerender.

the LoadViewState and LoadPostback event occur between Pages OnInit and
OnLoad events. They recursively walk the control tree to fire the events.
Your control and its children must exist after onit fire, for them to
receive the LoadViewState and LoadPostbackData events.

if you want your custom controls children to handle postback and viewstate
data, then you should create them in the CreateChildControls overload and
call EnsureChildControls in your OnInit.

-- bruce (sqlwork.com)
"Beavis" <mu**********@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
I hate to repost a message, but I am still at the same point where I
was when I originally posted, and hopefully someone else will see this
one...

Ok, so I have gone off and documented the lifecycle of a page with a
custom composite control on it. You can find that document here:
http://www.ats-engineers.com/lifecycle.htm
Now, I am working on a much more complex grid example, and according to

my findings, the order should be like so:
Page Constructor
Page OnInit
Page OnLoad Enter
Page Instantiates Composite Control
Control Constructor Enter
Control Adds Button
Control Constructor Exit
Control OnInit
Page OnLoad Exit
Control OnLoad
Page PreRender
Page SaveViewState
Control SaveViewState
Control OnUnLoad
Page OnUnLoad
The document I linked to above shows the code that I used to produce
this output, and I have stepped through it multiple times to verify
that this order is true.
Now my problem is that in my MUCH more complex Custom Control, I watch
the code go from the controls constructor, to the pages OnPreRender
method, skipping the controls oninit and onload methods (which will
skip the LoadViewState method if it is a postback). There has gotta be
something simple wrong with my other composite control. However that
control is about 700 lines of code, and I don't expect anyone to go
through it, especially considering that it uses about 10 other custom
classes that I wrote.
So without me getting into too much detai, the question is what could
cause a controls oninit to not fire. This composite control inherits
from PlaceHolder, just like the example I site in my page I referred to

above, so that shouldn't be the problem. The control is being added to
the page just as in the above example as well. However, I am trying to
get it to load the view state, and those methods are never called
either, it's like it isn't a System.Web.Control at all...
Any ideas?

Andy Baldwin

Jun 2 '06 #2
Good to know, thank you for your answer, I understand the question was
a bit convoluted :D

Thanks again, i will try that out and let you know my findings

AB

Jun 5 '06 #3
Ok, so that helped a lot, the problem was that I wasn't actually adding
the control to the page, rightfully so, I wanted some other things to
get checked out and fiddled with before it was actually generated.
Adding the grid control un initialized though worked... kinda hard to
explain, but thanks you got me on the right track!

Thanks again

AB

Jun 5 '06 #4

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

Similar topics

10
2294
by: dx | last post by:
I have the Microsoft Press: Developing Microsoft ASP.NET Server Controls and Components book. It's starting to shine some light on control development but there is something about composite...
3
2541
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
6
2191
by: Shimon Sim | last post by:
I have Panel control on the page. I am handling Init event for it. It doesn't seem to fire at all. Why? Thank you Shimon.
0
1390
by: multiformity | last post by:
Ok, so I have gone off and documented the lifecycle of a page with a custom composite control on it. You can find that document here: http://www.ats-engineers.com/lifecycle.htm Now, I am...
1
3952
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
0
7223
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
7321
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
7377
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...
0
5623
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,...
0
4702
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
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
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 ...
0
412
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.