Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

CSS/Control Adapters - The word is almost out

Posted on May 2, 2006

I have been developing some control adapters over the last month. Control adapters are really cool stuff for ASP.Net. They allow you to modify the rendering behavior of a control in a way that is independent from the control and the web site code. Scott Guthrie posted about control adapters late last year and again more recently.

One of the greatest uses I have come across for control adapters is for developers to use controls that they are familiar with, such as the intrinsic ASP.Net controls, but modify the html they produce to be more suitable to the application. I am involved in a web project that requires CSS to be used for document layout rather than tables. By using adapters, I can allow the developers to use a FormView control which they are familiar with and the adapter will take over the rendering of that control to ensure that tables are not rendered.

I was going to put out an example of creating adapters, but it looks like the ASP.Net crew might beat me to it. I kind of suspect their solutions might be different to mine so it will be interesting to see what they come out with.