Introduction

Web parts are the new building blocks of personalization in ASP.NET 2.0. Any control—whether a standard server control, custom control, user control, or web part control—can be used as a web part without modification.

In its simplest form, a web part consists of an ASP.NET server or user control that takes advantage of the Web Parts control set, which is a group of structural components consisting of the following minimum set:

WebPartManager control

Responsible for managing all other web part controls on the page

WebPartZone control

Defines an area on a page where web parts can be placed

CatalogZone control

Responsible for managing the user interface that displays the available web parts and provides the user the ability to select web parts and add them to WebPartZones

Creating a web part and using the Web Parts control set on an ASP.NET page is a natural first step in learning how to build web parts and is the subject of this chapter’s first recipe.

As you create a stable of web parts, you will find you want to reuse them on many pages in your applications, yet having to declare each web part on each page can be a stumbling block. Creating a reusable web parts catalog circumvents this issue and is the subject of the chapter’s second recipe.

ASP.NET server controls and user controls can be effective when used as web parts. Nevertheless, you may need additional functionality not provided by these controls—for example, when you want the ability to build your web parts ...

Get ASP.NET 2.0 Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.