Creating controls in ASP .Net Controls are a useful way of distributing a custom, repeatable functionality with or without UI and typically used within and across an organization.
Previous COM and ActiveX era had serious limitations on this front as they required permissions for each control to be accepted inside the organizations. ASP .Net has replaced this with a nice model which do not require local permissions any more. The newer framework are not permitted with any access to the local disk, which in turn makes them loadable without any permissions.
These custom controls can be created in either of the following 3 methods.
- Creating as a composite control : This method uses and combines the existing controls to give a custom functionality which can be used across different projects by adding to the control library. This can provide for event bubbling from child controls to the Parent container, custom event handling and properties. The CreateChildControls function of the Control class should be overridden for creating this custom control. This can also support design time rendering of the control.
- Deriving from an existing control : This method of creating a custom control derives from an existing ASP .Net control and customizing the properties that we need. This also can support custom event handling, properties etc.,
- Creating a control from Scratch : This method is the one which needs maximum programming. This method needs even the HTML code for the custom controls to be written by the programmer. This may also need one to implement the IPostBackDataHandler and IPostBackEventHandler interfaces. A detailed explanation with example for this is available at Rendering Custom Controls Sample in MSDN.