Web Control Libraries
Is everything we described above really possible? Absolutely, in fact many developers aren’t even aware this is possible with the .NET framework or simply forget they have this feature at their disposal. Web control libraries are probably one of the greatest advancements made in Web development through ASP.NET.
A web control library is a type of project available in Visual Studio.NET. As a project, it is simply compiled into a .NET assembly and will contain one or more custom web controls. These web controls can then be used on your own ASP.NET Web Forms. In fact, since the library is a compiled assembly, you can add your own custom controls to the Toolbox in Visual Studio.NET and use drag-drop features just like any other web control.
This is all possible through the use of inheritance. To grasp the concept you have to think in terms of classes and code, instead of visual components on a web page. Every ASP.NET control is nothing more than a class defined in the .NET framework. As such, you are free to inherit from these classes to suit your own needs.
Your custom web control therefore, is simply a class definition which inherits from an existing control in the .NET framework. In fact you can even create composite controls which are aggregates of multiple controls. You could theoretically create a single component which consisted of a Label, 2 Textboxes and a submit button. The possibilities are literally endless.
The trick to creating custom controls which will still be rendered correctly in the visual designer for Visual Studio.NET is to derive from a single explicit control. Explicit meaning non-generic because by default your control will inherit from the generic class “WebControl”, which has no real meaning in terms of a web page. So you want to try and choose a specific single control if possible, such as a Textbox, Button, Label etc…