views:

61

answers:

1

My understand of Control Adapters is that they're designed to allow different HTML rendering for different browsers (thus, you register them in the .browsers file...).

However, it appears people are just registering adapters for the default browser and are using them to generally override the Render method of ASP.Net controls.

Do you believe this is true? If so, why wouldn't you just inherit from a control and override the Render method that way, rather than use an adapter?

A benefit of overriding is that you can add more properties to it, which you can't do with adapters.

I just want to make sure I'm not missing some secret sauce that makes adapters better than overriding.

+1  A: 

Yes, it's quite common to register adapters for the default browser. The main idea behind this is to override the rendering functionality for existing controls. E.g. The so called 'Css Friendly' control adapters - this effort was largely to make the controls produce more standards compliant html.

Basically the thing you are missing here is that you can drop a set of control adapters aimed at the default browser on an existing site that uses the standard asp.net controls and get 'better' or 'different' markup without having to change your site to use custom controls that you have created.

Steve Willcock
I wonder if Microsoft will ever abandon the concept of browser-specific adapters and make the adapters more general, since everyone seems to be using them this way anyway.
Deane
The browser specific adapters are really useful for rendering mobile / device specific content too, so even with a 'standard' main browser set (IE8, Firefox, Chrome, Opera) that don't require specific rendering, there'll still be a place for mobile /device specific browser rendering, and the adapter architecture can handle this requirement quite well so I don't see the idea of browser specific adapters going away anytime soon.
Steve Willcock