WHAT YOU WILL LEARN IN THIS CHAPTER:
- What user controls are, how they look, and why they are useful
- How to create user controls
- How to consume (or use) user controls in your pages
- How you can improve the usefulness of user controls by adding coding logic to them
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
In addition to the master pages, themes, and skins discussed in Chapter 6, ASP.NET has another feature that enables you to create reusable and thus consistent blocks of information: user controls.
User controls enable you to group logically related content and controls together so they can be treated 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.
You typically use a User Control for content that gets used in a few pages in your site. For example, you can build a user control that displays a banner that is shown on some, but not all pages, as you’ll see in this chapter.
By the end of this chapter, you’ll have a firm understanding of what user controls are and how they work, enabling you to create functional, ...