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:

Hope this helps,

Scott

2 Comments

  • Yes, more resources on the Control Adapter Architecture would be great.



    To allow use of the default ASP.NET controls in XHTML/CSS based sites, I'm currently using an XSLT response filter to convert a Treeview into threaded bullet lists and Wizard control from tables into a flexible div structure for custom placement of the step links. Perhaps not the most recommended approach, but works pretty efficiently and a small bit of XSLT is nothing compared with writing custom controls. But making these accessibility/render changes deeper in the code with out of the box controls would be a great help.



    In the XHTML/CSS/AJAX world, ASP.NET hardly gets a mention compared with Ruby Rails and other frameworks. But ASP.NET 2.0 really makes building so called Web 2.0 apps a lot easier. And I'd suggest a lot more future proof than with the current flavour of the month web frameworks.



  • And the inevitable XAML adapters for ASP.NET controls samples appear on a blog somewhere in 5... 4... 3... 2... ;-)

Comments have been disabled for this content.