My last two blog entries have focused on the RoundedCorners Web control I created, which displays text within a box with rounded corners. (See a live demo or read more about this control.) One of the most requested feature additions has been the ability for the control to contain nested content, and to display this nested content within the box with rounded corners. That is, a page developer could use the following markup:
<skm:RoundedCorners runat=”server” ...>
<asp:DataGrid ...>
...
</asp:DataGrid>
</skm:RoundedCorners>
And the result would be a DataGrid within a box with rounded corners. Well, adding this functionality wasn't too challenging, but the task that's facing me now is creating a rich design-time experience, which is proving to be harder than expected. Ideally, the design-time experience would be similar to that of the Panel Web control, where a page developer could simply drag and drop Web controls from the Toolbox into the RoundedCorners control. From my research (primarily Developing Microsoft ASP.NET Server Controls and Components and picking through Reflector), I found that you need to create a Designer class that derives from the ReadWriteControlDesigner class. This, along with setting the ParseChildren and PersistChildren class-level attributes correctly, will automatically will allow a page developer to drag and drop controls within the custom server control. However, the ReadWriteControlDesigner class does not call the GetDesignTimeHtml() method, which is typically used in a custom Designer class to tailor the HTML used to render the control in the VS.NET Design tab.
Instead, the ReadWriteControlDesigner class creates what appears to be a DHTML-aware canvas that you can use to tailor the look of the control in the Design tab. I was unable to find what, exactly, the rendered HTML is for this canvas, but it appears to be a <span> or <div>. You can programmatically specify CSS properties or HTML attributes for this canvas, such as backgroundcolor, width, height, font, border, etc. But I don't see that there's any possible way to customize the actual HTML that comprises this canvas. See, I don't want a simple <span> or <div>, I want a 3x3 <table> in there, which would show a potential title for the box, and the places where the rounded corners would appear. But with a custom Designer derived from ReadWriteControlDesigner class, I can't find out how to control this, if it's at all possible.
Has anyone had any luck creating a custom Designer for a server control that extends the ReadWriteControlDesigner class and allows for a finer degree of customization of the HTML in the VS.NET Designer, or is this just not possible? Finally, any opinions on having a substandard design-time experience? Would it be worth it to have a control with more features (namely control nesting)?