Dynamic Composite Controls And Their Child Control Collection

Discussion in 'ASP .Net' started by Harry, Apr 15, 2004.

  1. Harry

    Harry Guest

    Hello,
    I have a composite WebControl that I'm dynamically instantiating at
    runtime using Reflection. When I create a new instance of my control I
    immediately iterate through it's child control collection (it has
    about 4 child controls). The problem is none of these controls are
    loaded or accessible when I create the instance since, I believe, they
    are created by the server at a later point in time. How could I force
    my composite control to load its child controls so I can perform my
    iteration?

    I don't have this problem when dealing with UserControls as the
    LoadControl method creates a new instance of the UserControl and loads
    all of it's associated child controls in its control collection.


    - Harry
    Harry, Apr 15, 2004
    #1
    1. Advertising

  2. Harry

    bruce barker Guest

    your composite controls needs to call EnsureChildControls. this will force a
    call CreateChildControls.

    -- bruce (sqlwork.com)




    "Harry" <> wrote in message
    news:...
    > Hello,
    > I have a composite WebControl that I'm dynamically instantiating at
    > runtime using Reflection. When I create a new instance of my control I
    > immediately iterate through it's child control collection (it has
    > about 4 child controls). The problem is none of these controls are
    > loaded or accessible when I create the instance since, I believe, they
    > are created by the server at a later point in time. How could I force
    > my composite control to load its child controls so I can perform my
    > iteration?
    >
    > I don't have this problem when dealing with UserControls as the
    > LoadControl method creates a new instance of the UserControl and loads
    > all of it's associated child controls in its control collection.
    >
    >
    > - Harry
    bruce barker, Apr 15, 2004
    #2
    1. Advertising

  3. Harry

    Harry Guest

    Bruce,
    How would I go about doing this? I ahve tried calling the method
    this.EnsureChildControls() in my composite WebControl's constructor,
    but this doesn't work.

    - Harry


    "bruce barker" <> wrote in message news:<#>...
    > your composite controls needs to call EnsureChildControls. this will force a
    > call CreateChildControls.
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    >
    > "Harry" <> wrote in message
    > news:...
    > > Hello,
    > > I have a composite WebControl that I'm dynamically instantiating at
    > > runtime using Reflection. When I create a new instance of my control I
    > > immediately iterate through it's child control collection (it has
    > > about 4 child controls). The problem is none of these controls are
    > > loaded or accessible when I create the instance since, I believe, they
    > > are created by the server at a later point in time. How could I force
    > > my composite control to load its child controls so I can perform my
    > > iteration?
    > >
    > > I don't have this problem when dealing with UserControls as the
    > > LoadControl method creates a new instance of the UserControl and loads
    > > all of it's associated child controls in its control collection.
    > >
    > >
    > > - Harry
    Harry, Apr 16, 2004
    #3
    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. sleigh
    Replies:
    1
    Views:
    2,685
    sleigh
    Feb 12, 2004
  2. Øyvind Isaksen
    Replies:
    1
    Views:
    964
    Øyvind Isaksen
    May 18, 2007
  3. Chad Scharf
    Replies:
    3
    Views:
    867
    Chad Scharf
    Oct 18, 2007
  4. Buzz
    Replies:
    4
    Views:
    181
  5. David Boike

    Child controls in Composite Controls not firing events

    David Boike, Aug 7, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    312
    David Boike
    Aug 7, 2003
Loading...

Share This Page