.NET 2.0 - Server Control Base Class
posted on 2005-05-31 at 23:47:08 by Joel Ross
I'm starting to research what it's going to take to write the Tourney Bracket Control in ASP.NET 2.0, and I found the first cool new feature.
There's a new base class for custom controls. Before, if you were doing anything remotely complicated (i.e, not adding functionality to an existing server control), your choices were Control and WebControl.
Now you have a new choice: CompositeControl. This is specifically designed for…you guessed it. Composite controls. It implements INamingContainer for you, and any time the controls collection is accessed (both run-time and design-time), it calls EnsureClientControls() for you.
Changing our base class was painless - I already implemented INamingContainer and already overrode EnsureClientControls(), so it was just a matter of changing Control to CompositeControl.
Categories: ASP.NET