Composite Control Problem

M

Mike Dando

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#
 
J

John Saunders

Mike Dando said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top