User Controls and Web Custom Controls

In their infinite wisdom Microsoft decided that there should be two kinds of controls that you could create: User Controls and Web Custom Controls. User Controls have an associated ascx file that contains ASP.NET/HTML markup. They're a nice declarative way to specify the layout of a control. Web Custom Controls, on the other hand, are just ordinary cs (C Sharp) files, and their layout/representation is achieved through dynamic allocation and placement of controls. I understand the need for the two approaches. Sometimes the layout of a page is such that you can't easily (or at least clearly) express it via the declarative mechanisms of ASP.NET/HTML.

But Microsoft seems to have crippled the User Controls in ways that I just don't get. For example, User Controls don't have any provision for design time support. That is, you can't put them in the Toolbox, and you can't control their design time representation. That makes them completely unusable as a way of actually distributing controls to others. Furthermore, the use of the ParseChildren(false) attribute is not properly supported. This attribute is needed when you are designing a control that can contain arbitrary mark-up (e.g. various types of layout controls). But if you mark a User Control as ParseChildren(false) and give it a contained HTML element like a DIV, then in design-view DevStudio complains that there was an error creating the control because the control has no property called DIV. This is the behaviour one expects if the control is marked as ParseChildren(True). Oddly enough, the is only a design time issue. The control actually works as expected. It seems Microsoft managed to support the run-time behaviour correctly, but didn't deal with the design time issues.

To their credit, the Microsoft web site does point out that User Controls are only appropriate for fairly static content, and they do explicitly indicate that there is no design time support for them. But if they didn't want me using the ParseChildren(false) attribute, then they could have easily detected it and put up a much more friendly error message that that attribute was not supported for User Controls.