CreateChildControls?

Discussion in 'ASP .Net' started by George Ter-Saakov, Jul 28, 2003.

  1. Hi.
    I have an HTML page were I load controls dynamically.

    So I overwrote the CreateChildControl but I found some problem.
    First time when page is called the CreateChildControl is called after
    Page::Load
    But when it's a post back the CreateChildControl is called before
    Page::Load.


    Is there any reason for that?


    George.
     
    George Ter-Saakov, Jul 28, 2003
    #1
    1. Advertising

  2. The CreateChildControls is called in a composite control before the child
    controls are needed. The child controls more than likely need to processes
    some postback data ( or events ) and thus, they are required to be around
    before the page load.

    It shouldn't matter when the CreateChildControls is being called as far as
    the behavior of your composite control, but I would definitely consider
    adding EnsureChildControls() before every method or property that access the
    child controls and don't concern your self of the "first" time it is called.

    HTH,

    bill



    "George Ter-Saakov" <> wrote in message
    news:...
    > Hi.
    > I have an HTML page were I load controls dynamically.
    >
    > So I overwrote the CreateChildControl but I found some problem.
    > First time when page is called the CreateChildControl is called after
    > Page::Load
    > But when it's a post back the CreateChildControl is called before
    > Page::Load.
    >
    >
    > Is there any reason for that?
    >
    >
    > George.
    >
    >
     
    William F. Robertson, Jr., Jul 28, 2003
    #2
    1. Advertising

  3. Thanks.
    Did not know that this method existed.

    George.

    "William F. Robertson, Jr." <> wrote in message
    news:...
    > The CreateChildControls is called in a composite control before the child
    > controls are needed. The child controls more than likely need to

    processes
    > some postback data ( or events ) and thus, they are required to be around
    > before the page load.
    >
    > It shouldn't matter when the CreateChildControls is being called as far as
    > the behavior of your composite control, but I would definitely consider
    > adding EnsureChildControls() before every method or property that access

    the
    > child controls and don't concern your self of the "first" time it is

    called.
    >
    > HTH,
    >
    > bill
    >
    >
    >
    > "George Ter-Saakov" <> wrote in message
    > news:...
    > > Hi.
    > > I have an HTML page were I load controls dynamically.
    > >
    > > So I overwrote the CreateChildControl but I found some problem.
    > > First time when page is called the CreateChildControl is called after
    > > Page::Load
    > > But when it's a post back the CreateChildControl is called before
    > > Page::Load.
    > >
    > >
    > > Is there any reason for that?
    > >
    > >
    > > George.
    > >
    > >

    >
    >
     
    George Ter-Saakov, Jul 28, 2003
    #3
  4. I can type the EnsureChildControls() really fast since I use it about 4000
    times in each of my controls. Typically on the properties for the composite
    controls.

    happy coding.

    bill

    "George Ter-Saakov" <> wrote in message
    news:...
    > Thanks.
    > Did not know that this method existed.
    >
    > George.
    >
    > "William F. Robertson, Jr." <> wrote in message
    > news:...
    > > The CreateChildControls is called in a composite control before the

    child
    > > controls are needed. The child controls more than likely need to

    > processes
    > > some postback data ( or events ) and thus, they are required to be

    around
    > > before the page load.
    > >
    > > It shouldn't matter when the CreateChildControls is being called as far

    as
    > > the behavior of your composite control, but I would definitely consider
    > > adding EnsureChildControls() before every method or property that access

    > the
    > > child controls and don't concern your self of the "first" time it is

    > called.
    > >
    > > HTH,
    > >
    > > bill
    > >
    > >
    > >
    > > "George Ter-Saakov" <> wrote in message
    > > news:...
    > > > Hi.
    > > > I have an HTML page were I load controls dynamically.
    > > >
    > > > So I overwrote the CreateChildControl but I found some problem.
    > > > First time when page is called the CreateChildControl is called after
    > > > Page::Load
    > > > But when it's a post back the CreateChildControl is called before
    > > > Page::Load.
    > > >
    > > >
    > > > Is there any reason for that?
    > > >
    > > >
    > > > George.
    > > >
    > > >

    > >
    > >

    >
    >
     
    William F. Robertson, Jr., Jul 28, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    4
    Views:
    5,693
    Jonathan Williams
    Aug 7, 2003
  2. Lucas Tam
    Replies:
    1
    Views:
    774
    John Saunders
    Aug 17, 2003
  3. Alex
    Replies:
    6
    Views:
    2,218
    John Saunders
    Aug 26, 2003
  4. Arulraja
    Replies:
    3
    Views:
    1,406
    William F. Robertson, Jr.
    Oct 17, 2003
  5. DesignerX

    CreateChildControls... when and why?

    DesignerX, Oct 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,183
    DesignerX
    Oct 30, 2003
Loading...

Share This Page