473,665 Members | 2,820 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.Cont rol at all...
Any ideas?

Andy Baldwin

Jun 2 '06 #1
3 3001
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 LoadPostbackDat a events.

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

-- bruce (sqlwork.com)
"Beavis" <mu**********@g mail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.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.Cont rol 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
2309
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 controls that I don't understand... I've included a snippet from Chapter 12 below on Composite Controls: <start> Override the CreateChildControls method to instantiate child controls, initialize them, and add them to the control tree. Do not perform...
3
2550
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 consituent control caused a postback. for example a have a consituent controls with two buttons on it "button1" and "button2" I have registered my control for postbacks using
6
2203
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
1403
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 working on a much more complex grid example, and according to my findings, the order should be like so: Page Constructor Page OnInit
1
3957
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 DatalistItemTemplate : ITemplate { public void InstantiateIn(Control container)
0
8863
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
8779
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
7376
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...
1
6187
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
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
4186
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
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
2
1761
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.