Chapter 8. User Controls
Besides the master pages, themes, and skins discussed in Chapter 6, ASP.NET 3.5 ships with another feature that allows you to create reusable and thus consistent blocks of information: user controls.
User controls allow you to group logically related content and controls together which can then be used as a single unit in content pages, master pages, and inside other user controls. A user control is actually a sort of mini ASPX page in that it has a markup section and optionally a Code Behind file in which you can write code for the control. Working with a user control is very similar to working with normal ASPX pages with a few minor differences.
In versions of ASP.NET before 2.0, user controls were used often to create blocks of reusable functionality that had to appear on every page in the site. For example, to create a menu, you would create a user control and then add that control to each and every page in the site. Due to the ASP.NET support for master pages, you don't need user controls for these scenarios anymore. This makes it easier to make changes to your site's structure. Despite the advantages that master pages bring, there is still room for user controls in your ASP.NET web sites as you'll discover in this chapter.
This chapter covers the following topics:
What are user controls and how do they look?
How do you create user controls?
How do you consume user controls in your pages?
How can you improve the usefulness of user controls by adding ...