Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Composite Control Problem

Reply
Thread Tools

Composite Control Problem

 
 
Mike Dando
Guest
Posts: n/a
 
      12-02-2004
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#


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      12-02-2004
"Mike Dando" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
 
Mike Dando
Guest
Posts: n/a
 
      12-06-2004
Thanks John,

That has sorted out my rendering problem.

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:(E-Mail Removed)...
> "Mike Dando" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite vs non composite Controls Mike ASP .Net Web Controls 4 03-11-2005 05:47 AM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
Composite control with dynamic composite controls sleigh ASP .Net 1 02-12-2004 06:24 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net 0 07-01-2003 09:26 PM



Advertisments