O'Reilly logo

Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8User Controls

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

You can find the wrox.com code downloads for this chapter on the Download Code tab at www.wrox.com/go/begaspnet451. The code is in the Chapter 8 folder.

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required