Last post Nov 08, 2007 03:32 AM by Nai-Dong Jin - MSFT
Nov 06, 2007 07:42 PM|shapper|LINK
I am creating a custom control and I have the following:
Protected Overrides Sub CreateChildControls()
Me.ChildControlsCreated = True
Is EnsureChildControls needed?
Nov 06, 2007 10:14 PM|Googzie|LINK
No. Its not needed in createChildControls method because they do the samething.
Nov 07, 2007 11:42 PM|Nai-Dong Jin - MSFT|LINK
It depends on different scenarios.
Actually, EnsureChildControl method determines whether the server control contains child controls. If it does not, it creates child controls.
This method first checks the current value of the ChildControlsCreated property. If this value is false, the CreateChildControls method is called.
ASP.NET calls it this method when it needs to make sure that child controls have been created. In most cases, custom server control developers do not need to override this method. If you do override this method, use it in a similar fashion as its default
For more information, see:
Nov 08, 2007 12:33 AM|Googzie|LINK
Jin then you can help clarify this isnt ChildControlsCreated property set to true whenever code comes CreateChildControls() ? if thats the case why call EnsureChildControls in createChildControls()?
Nov 08, 2007 03:32 AM|Nai-Dong Jin - MSFT|LINK
isnt ChildControlsCreated property set to true whenever code comes CreateChildControls() ? if thats the case why call EnsureChildControls in createChildControls()?
Googzie, you are right. Sorry for not seeing call the methoeds in CreateChildControls() in the orignial post. That's not needed.