Wrox Programmer Forums
BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X
This is the forum to discuss the Wrox book Professional Web Parts and Custom Controls with ASP.NET 2.0 by Peter Vogel; ISBN: 9780764578601
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 11th, 2006, 11:08 PM
Authorized User
Join Date: Jan 2006
Posts: 13
Thanks: 6
Thanked 1 Time in 1 Post
Default MyBase.CreateChildControls


On page 72 you said we can enable design time support and avoid the CreateChildControls method to be called twice if we set Me.ChildControlsCreated = True. I understand this part, but why would you need to call


immediately above

Me.ChildControlsCreated = True



Old January 15th, 2006, 06:26 PM
Authorized User
Join Date: Dec 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

That's a very good question since MyBase.CreateChildControls is going to set ChildControlsCreated anyway.

It's a good practice to always call the base method to make sure that any necessary work that the base method carries out is done. In this case, for instance, calling the base method would take care of setting ChildControlsCreated.

I should have put in one line or the other but not both. Since the sample was intended to show how to use ChildControlsCreated, I should have omitted the call to the base method. While calling the base method does no harm here, it also does no good.

In fact, throughout the book, I typically omit the call to the base method in order to focus attention on the code technique that I'm demonstrating. That would have been an excellent choice here.

When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.

- Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"

Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite's CreateChildControls called twice bmains .NET Framework 2.0 0 July 27th, 2005 10:53 AM
MyBase Keyword Little Shell VB.NET 2002/2003 Basics 2 May 2nd, 2005 05:18 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.