ASP.net Control adapters V1.0
ASP.NET 2.0 has given web application developers a lot of improvements over 1.1 despite the buggy Development Environment. One of my favorites is the Control Adapter Architecture, this gives us the ability to change the way a control renders without going to the trouble of creating our own custom control to replace the control we want to tweak.
The process is actually very simple and the results can be extremely good.
One of the big applications for this is to implement a control adapter that will render markup that will be more CSS compliant or even rewrite the rendering so that instead of tables you render using UL and LI tags. In essence you get to take control of the rendered output rather than relying on what you get ‘out of the box’.
I won’t go into technical detail in this post as frankly there are better resources out there, but in order to take advantage of this technology all you need is an adapter file, simply a class that overrides the RenderContents method, this class needs to inherit the
Now you have part two of the two part partnership required to customize your control, part one is of course the control itself. To bring the two together we have a middleman that sits in the App_Browsers folder of your application. This .browser file contains the XML that maps the control to it’s adapter and is where a lot of the ‘magic’ happens. It’s possible, using this file, to map your control to different adapters depending on the browser ASP.NET knows to check the browser and will point the control to the correct adapter as required. The browser file contents look a bit like this:
2 <browser refID=“IE6to9“>
4 <adapter controlType=“System.Web.UI.WebControls.DropDownList“
5 adapterType=“AlgSoftware.Web.Controls.Adapters.DropDownListAdapter“ />
If you are interested in finding out more about this then I recommend you download the latest release from here, You may also want to read through Scott Guthrie’s latest post about the adapters, as always Scott has included loads of great info as well as all the links you’ll need to get on top of this technology and improve your applications.