Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Event Fires after CreateChildControls

Thread Tools

Event Fires after CreateChildControls

John Bankhead
Posts: n/a
I have created a C# control that creates its objects within
CreateChildControls. One of those objects is a button which I have attached
to a command event. The command event fires after CreateChildControls runs,
but I want the clicking of the button to have an effect on what items
CreateChildControls creates. Is this possible? Obviously I can make this
happen by setting a value on an object on the client side and reading it in
CreateChildControls. But still, I am curious.

John Bankhead
Reply With Quote
Teemu Keiski
Posts: n/a

you could do this in Click event handler (of the Button) or have customized
routine to do it (assuming we are inside the custom control logic all the

a) Clear child controls collection by calling Controls.Clear() and clear
child state by calling ClearChildViewState()
b) set ChildControlsCreated to false
c) Do the stuff that has impact on child control creation
d) finally call EnsureChildControls which willl call CreateChildControls (it
does that when ChildControlCreated flag is false)

So simply saying, you recreate the control in such scenario.

Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

Reply With Quote

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
Simple composite control fires event fires first time but not second ASP .Net Web Controls 3 05-13-2009 03:19 PM
When user press F5 after a button click event, the click event fires again! Max2006 ASP .Net 2 09-19-2007 05:37 AM
createchildcontrols fires before click event ASP .Net Web Controls 1 07-04-2007 10:56 AM
CreateChildControls Event before Click Event Mark Sisson ASP .Net Building Controls 1 07-17-2003 03:46 AM
CreateChildControls Event before Click Event Mark Sisson ASP .Net Web Controls 1 07-17-2003 03:46 AM