Chapter 15. Custom and User Controls
This chapter looks at controls which you, the developer, will create for your websites. They can be divided into two main categories: custom controls and user controls.
User controls are segments of ASP.NET pages that can be reused from within other pages. This is similar to “include files” familiar to ASP developers. However, user controls are far more powerful. User controls support properties and events and, thus, provide reusable functionality as well as reusable HTML.
Custom controls are compiled controls that act, from the client’s perspective, much like ASP.NET controls. You can create custom controls in one of three ways:
By deriving a new custom control from an existing control (e.g., deriving your own specialized text box from
asp:TextBox
). This is known as a derived custom control.By composing a new custom control out of two or more existing controls. This is known as a composite custom control.
By deriving from the base control class, thus creating a new custom control from scratch. This is known as a full custom control.
All three of these methods, and the three control types that correspond to them, are variations on the same theme.
Tip
Strictly speaking, user controls are a subset of custom controls, with the emphasis on ease of creation as you’ll see in the next section.
Get Programming ASP.NET 3.5, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.