I ran across an interesting problem today, and I'm surprised that I have never read anything online or in ASP.NET books on the topic.
Basically I created a Wizard Control that will facilitate the common UI task of separating a long task into steps. The idea of a Wizard with Next/Previous buttons has been a foundation of windows applications since the beginning. Providing a similar interface for the web can help a lot.
The control provides a table that looks like this:
so I have the control developed, all is well, the html looks all nice and neat like this:
<cc1:Wizard id="wizard1" runat="server" HeaderText="New User">
<cc1:WizardStep id="step1" runat="server" ValidationGroup="step1Group">
I am inside step 1!!!
</cc1:WizardStep>
</cc1:Wizard>
Now what if I wanted to encapsulate some of the controls in step1 into it's own user control? Sounds like it would tidy things up a bit. So I did this, and everything was okay. Until I wanted to make each ascx file in charge of validating and saving itself...
So I decide to instead, derive from FoundationWizardStep in the ascx code-behind. This way I could provide a couple public properties and method for validating and saving the form fields. This gives you an error though, because you cannot make a user control (one with an ascx file) derive from System.Web.UI.Control. Instead it must derive from System.Web.UI.UserControl. What's the difference, you ask? Well I suppose the it takes some extra steps in rendering to allow for rich designer support, but aside from that? Not much.
Now if I make FoundationWizardStep in turn derive from UserControl, I get even more weird behavior. I get a run-time exception in the html that the FoundationWizard doesn't have a child property of type FoundationWizardStep...
Now I have resolved the problem by eliminating the ascx control and making it a complete server control (class only). Anyone have ideas as to why this happened?