In an object-oriented environment like .NET, the encapsulation of code into small, single-purpose, reusable objects is one of the keys to developing a robust system. For instance, if your application deals with customers, you might want to consider creating a customer's object that encapsulates all the functionality a customer might need. The advantage is that you create a single point with which other objects can interact, and you have only a single point of code to create, debug, deploy, and maintain. In this scenario, the customer object is typically known as a business object because it encapsulates all the business logic needed for a customer.
Several other types of reusable objects are available in .NET. In this chapter, we concentrate on discussing and demonstrating how you can create reusable visual components for an ASP.NET application. The two types of reusable components in ASP.NET are user controls and server controls.
A user control encapsulates existing ASP.NET controls into a single container control, which you can easily reuse throughout your Web project.
A server control encapsulates the visual design, behavior, and logic for an element that the user interacts with on the Web page.
Visual Studio ships with a large number of server controls that you are probably already familiar with, such as the Label, Button, and TextBox controls. This chapter talks about how you can create custom server controls and extend existing server controls. ...