DotNetRocks on Server Controls, And More

posted on 2005-10-05 at 20:33:25 by Joel Ross

As a server control developer, I was very interested in listening to the latest DotNetRocks show. Overall, it was a great show, and while a lot of it was review, there were a few good nuggets in there, as well as some validation that I'm doing things The Right Way. If you're never developed a server control, it's a great introduction to them - why you'd do it and how you'd do it.

Anyway, one thing that I've never really thought about was the different types of server controls. Miguel says there's three: Inherited, rendered, and composite. The composite is the most common I've seen, with the inherited being second. Rarely do I see rendered controls, mainly because they're too complicated to get working correctly, despite them being (slightly) faster than composite controls. It's also interesting to note that composite controls are, at their core, a collection of rendered controls.

The Tourney Bracket Control, by the way, is a composite control. It's actually a server control with other server controls in it that are made up of basic rendered controls.

There were a few things that were said that I didn't agree with. Well, not that I didn't agree with, but that I do differently. First, I don't typically statically declare my child controls in the server control. Most of the server controls I've worked on are dynamic - I don't know how many child controls I'll need until I look at the way it's configured. In the case of the Tourney Bracket Control, I can't statically declare how many match ups there will be because I don't know how many there will be until I look at the configuration at run-time (or design-time). So I create them dynamically as I need them.

The other thing I do differently is how I build my controls collection. I don't know why I do it this way, but looking back, I use the CreateChildControls() method to create all controls that need to be involved in the postback/viewstate process. That way, I can get data in and out of the control as I need it. But, I do the non-essential controls in an override of OnPreRender(). So if a table is needed to contain some controls, I add it there, rather than in the CreateChildControls() method, as described by Miguel.

The other DotNetRocks related item has to do with Carl's expansion of the DotNetRocks show into a family of shows. From his latest newsletter:

This is a weekly camtasia-based interview show. Think of a combination webcast and DNR interview. The guest will drive real-world demos and explanations using screen-cam technology from TechSmith ( 60 minutes

This will either be a video or audio short featuring yours truly talking with ASP.NET guru Scott Hanselman as he takes us on a journey of problem-solving and the intelligent application of technology. 20 minutes

The 64-Bit Question
This is an audio-only call-in quiz show in which the teeming millions compete for prizes by answering questions about .NET and computing in general. 30 minutes

It looks like it's time to make room for some new shows! The Hanselminutes should be a good one.

Technorati Tags: |

Categories: ASP.NET