The CatalogPart class is a base class for special controls that reside in CatalogZoneBase zones. These derived CatalogPart controls provide catalogs of Web server controls that end users can add to a Web page. Use CatalogPart controls in a Web application when you want to provide end users with the flexibility to change the functionality of a Web page by adding or removing server controls.
A catalog is simply a list of one or more available Web server controls (including WebPart controls, ASP.NET server controls, and custom or user controls) that users can add to a Web page. A catalog has a number of common characteristics, including instruction text for end users; text to describe each server control; helper controls to select the server controls and add them to the page; a common header, footer, and border; and a number of style attributes.
There are three types of CatalogPart controls provided with the Web Parts control set, as described in the following table. Each type of CatalogPart control contains server controls that are added to a page from a different source.
Important: |
|---|
| Controls that inherit from the CatalogPart class can reside only in zones derived from the CatalogZoneBase class. |
| Control | Description |
| PageCatalogPart | Contains controls that have been closed on a page, and that can be reopened (added back to the page) by users. The controls in this type of catalog are controls that were already added to the page from another source, and were then closed by a user. |
| DeclarativeCatalogPart | Contains server controls declared within a DeclarativeCatalogPart control, which is itself contained in a CatalogZoneBase zone in the markup of a Web page. |
| ImportCatalogPart | Provides the user interface (UI) for a user to upload a control's definition file (an XML file defined by a schema, that contains state information) to a catalog, so that the control can be added to a Web page. The controls themselves do not appear in this type of catalog; the catalog is just a mechanism for accessing the definition files for external controls so they can be added to a page. |
The CatalogPart class inherits from the base Part class, so that it has the common behavior of other part controls in the Web Parts control set. In addition, it adds some members that are useful for the catalog functionality. The DisplayTitle property gets the actual string that is currently being displayed as the title of the control. The value of this property can be the same as the value of the Title property or, if no value has been assigned to that property, a default value supplied by the .NET Framework. The WebPartManager and Zone properties both provide convenient access to the two essential objects that control the life cycle of a CatalogPart control: the WebPartManager control, and the CatalogZoneBase zone that contains the CatalogPart control, respectively.
The CatalogPart class also contains several methods. The GetAvailableWebPartDescriptions method is declared as an abstract method that must be implemented by inheritors. Its intended purpose is to return a collection of descriptions of the controls in the catalog. A related method, GetWebPart, is also declared as abstract and must be implemented by inheritors. This method is intended to return an instance of a WebPart control based on a description that is passed to the method as a parameter.
Notes to Inheritors
Because the
CatalogPart class is abstract, you cannot use it directly on a Web page. The Web Parts control set provides three
CatalogPart controls (listed in the table in the Remarks section of this topic) that derive from the base class and that can be used on Web Parts pages. These controls should provide most of the features needed to create catalogs of Web server controls. However, you might have specialized needs that would require developing a custom
CatalogPart control. For example, you can create a special type of
CatalogPart control that makes server controls available through a Web service, or directly from a database. To do this, you must inherit from the
CatalogPart class. You must also override the abstract
GetAvailableWebPartDescriptions and
GetWebPart methods to provide an implementation that returns the
WebPart or other server controls, and their descriptions. You will also need methods to load the various server controls from your database or Web service.