Skip to Content
Beginning ASP.NET 3.5: In C# and VB
book

Beginning ASP.NET 3.5: In C# and VB

by Imar Spaanjaars
March 2008
Intermediate to advanced content levelIntermediate to advanced
766 pages
21h 15m
English
Wrox
Content preview from Beginning ASP.NET 3.5: In C# and VB

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET 4: in C# and VB

Beginning ASP.NET 4: in C# and VB

Imar Spaanjaars
Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Bill Evjen, Scott Hanselman, Devin Rader

Publisher Resources

ISBN: 9780470187593Purchase book