Friday, April 28, 2006

Adding functionality to already defined classes through Extender Providers

Today I've learned that there is a way to add extra functionality to already defined classes through ExtenderProviders. While in Windows Forms things are relativeley easy, in Asp.NET visual studio 2003 is broken and needs special hacks in order to work.

This is the link for how to use ExtenderProviders in ASP.NET:
Extender provider components in ASP.NET: an IExtenderProvider implementation

in my latest WebControls library I have a component called NiftyExtender. You drag and drop it on an ASP.NET page and in Visual Studio all Controls have extra filter functions like Glow, Emboss, Engrave, Flip, etc. There is no need for cumbersome inheritance, just add the component to an already made site and it works just fine.

The same applies to Windows Forms, but there it works by default, without the need for a special class and weird hacks. A Windows Forms example is the ToolTip object that I always wondered what it does. Well, you drag and drop it on a form, then all windows form components have a tooltip in the Misc section.

I am thinking of a validator ExtenderProvider that would add the necessary validation functions to all controls in a page or form.