What are they?
Custom controls are controls that are written 100% in code and are then compiled into a DLL. Then they can be registered and inserted much like a user control. The difference comes into what you can put in them and what you can do with them. They can provide the same high level that server controls do and don't have to be a bunch of other server controls together.
Vs. User Controls
Custom Controls |
User Controls |
- HTML rendering needs to be coded (no visual designer in VS.NET).
- Created totally in code and compiled as a complete class library.
- Easy to distribute and manage.
- Can have full use of the designer in VS.NET
- Can be referenced in the implementing page's code.
|
- As simple as web forms to create (just drag and drop in VS.NET).
- Created as an ASP.NET page but stripped and with the .ASCX extension.
(this is probably over-simplifying it).
- Sometimes has multiple text files and not as easy to distribute and incorporate.
- Little to no use of the designer in VS.NET
- Can't be referenced in the implementing page's code.
|
Functionality
I said earlier that they had a lot of functionality, and it's true. They can be built with the same functionality as server controls without the limitations of user controls. The downside is that it all has to be done through code, although you will find that it is actually quite simple to do.
For example, you can dynamically set the properties and handle events raised by the custom control, which you can't do in user controls.