ASP.NET 2.0 Control Adapter Architecture
November 2006 Update: I've posted two detailed tutorial walkthroughs that discuss the ASP.NET CSS Control Adapters and how to use them in much more detail. You can check them out here and here. I'd also recommend checking out my ASP.NET Tips, Tricks and Tutorials page for more good tutorials to read.
-----------------------------
Origional December 2005 Post: I posted last night about a few things we're working on to release in the near future. One of the topics that seemed to get the most interest was our plan to release some control adapters (with full source) that demonstrate how to build pure-CSS style based rendering implementations for some of the built-in ASP.NET server controls.
The architecture to-do this is pretty cool, and something we baked into ASP.NET 2.0 very early on in the project (early in the release we were planing to build mobile device adapters for all of the standard ASP.NET controls -- although we later backed off of this). What is nice about the architecture is that the renderings can be controlled completely independently of the controls developers program against (so developer used to using the asp:menu control continue to program against that object model -- regardless of whether it is table or css based output).
You can configure an alternative adapter render class for each ASP.NET control separately from your app code (this can be configured using .browser files -- so you can even specify different adapters based on the incoming user-agent). The ASP.NET control architecture then delegates to the adapter when it comes time to render -- and the adapter can handle all output generation (if you want to get even fancier you can override post-back and other life-cycle events with your adapters).
Here are a few links to articles on MSDN about how it works:
- Architecture Overview of Adapters
- Browser Definition Files
- Sample code to a simple adapter in the ASP.NET 2.0 QuickStarts
Hope this helps,
Scott