Composite Control Problem

Discussion in 'ASP .Net Web Controls' started by Mike Dando, Dec 2, 2004.

  1. Mike Dando

    Mike Dando Guest

    Hi,

    I have created a composite control which has some drop down lists, buttons
    and a list box.
    The control renders itself dynamically via CreateChildControls() according
    to a property set by the web form - page load.

    This is fine the first time the control is rendered. When any of the buttons
    on my control are pressed causing a postback,
    the CreateChildControls() is called before the web form page load. Hence the
    vital property is not set and the control
    fails to render and effectively disappears.

    Is this correct that page-load is called after my control has created it's
    child controls? If so how do I get around this problem? If not, what am I
    doing wrong?

    I can't use ViewState for the property as it is a 3rd party non-serializable
    object.

    Many thanks.
    Mike.

    VS.NET 2003 - C#
    Mike Dando, Dec 2, 2004
    #1
    1. Advertising

  2. "Mike Dando" <> wrote in message
    news:...
    > Hi,
    >
    > I have created a composite control which has some drop down lists, buttons
    > and a list box.
    > The control renders itself dynamically via CreateChildControls() according
    > to a property set by the web form - page load.
    >
    > This is fine the first time the control is rendered. When any of the
    > buttons on my control are pressed causing a postback,
    > the CreateChildControls() is called before the web form page load. Hence
    > the vital property is not set and the control
    > fails to render and effectively disappears.
    >
    > Is this correct that page-load is called after my control has created it's
    > child controls? If so how do I get around this problem? If not, what am I
    > doing wrong?
    >
    > I can't use ViewState for the property as it is a 3rd party
    > non-serializable object.


    CreateChildControls will be called as needed by ASP.NET. If you have a
    property whose setting would change the set of controls created in
    CreateChildControls, then the property setter should set
    ChildControlsCreated to false. This will cause the controls to be recreated
    some arbitrary time after the property is set.

    John Saunders
    John Saunders, Dec 2, 2004
    #2
    1. Advertising

  3. Mike Dando

    Mike Dando Guest

    Thanks John,

    That has sorted out my rendering problem.

    "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
    news:...
    > "Mike Dando" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> I have created a composite control which has some drop down lists,
    >> buttons and a list box.
    >> The control renders itself dynamically via CreateChildControls()
    >> according to a property set by the web form - page load.
    >>
    >> This is fine the first time the control is rendered. When any of the
    >> buttons on my control are pressed causing a postback,
    >> the CreateChildControls() is called before the web form page load. Hence
    >> the vital property is not set and the control
    >> fails to render and effectively disappears.
    >>
    >> Is this correct that page-load is called after my control has created
    >> it's child controls? If so how do I get around this problem? If not, what
    >> am I doing wrong?
    >>
    >> I can't use ViewState for the property as it is a 3rd party
    >> non-serializable object.

    >
    > CreateChildControls will be called as needed by ASP.NET. If you have a
    > property whose setting would change the set of controls created in
    > CreateChildControls, then the property setter should set
    > ChildControlsCreated to false. This will cause the controls to be
    > recreated some arbitrary time after the property is set.
    >
    > John Saunders
    >
    >
    Mike Dando, Dec 6, 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. Replies:
    0
    Views:
    705
  2. sleigh
    Replies:
    1
    Views:
    2,666
    sleigh
    Feb 12, 2004
  3. shapper
    Replies:
    6
    Views:
    942
    shapper
    Dec 26, 2007
  4. Chad
    Replies:
    0
    Views:
    209
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    247
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page