DeclarativeCatalogPart::GetAvailableWebPartDescriptions Method
Returns a collection of descriptions of the available WebPart controls in a catalog.
Assembly: System.Web (in System.Web.dll)
Return Value
Type: System.Web.UI.WebControls.WebParts::WebPartDescriptionCollectionA WebPartDescriptionCollection that contains a WebPartDescription for each control in a catalog.
The GetAvailableWebPartDescriptions method provides an implementation for the abstract base method declared in the CatalogPart class. The GetAvailableWebPartDescriptions method returns description information for each control in a catalog. A WebPartDescription object is an object that contains essential information about a WebPart control, including its ID, an object reference to the control, and the values of several important properties that are inherited from the Part class, such as Title and Description.
The GetAvailableWebPartDescriptions method improves performance. When a catalog is created, it needs some information about each control it contains, including a title, a description, an icon (if one exists), and an ID. Rather than having to create an instance of each control to get this information, a CatalogZoneBase zone that creates a catalog calls the GetAvailableWebPartDescriptions method for each control that will be in the catalog, and the call returns only the description information for the control.
The following code example shows how to use the GetAvailableWebPartDescriptions method. This example has four parts:
A user control that enables you to change display modes on a Web Parts page.
A source code file that contains two custom WebPart controls.
A Web page that contains a CatalogZone control and a DeclarativeCatalogPart control that references several server controls. The page also contains the event-handling code that calls the GetAvailableWebPartDescriptions method.
An explanation of how the example works when you load the page in a browser.
The first part of this code example is the user control that enables users to change display modes on a Web page. For details about display modes and a description of the source code in this control, see Walkthrough: Changing Display Modes on a Web Parts Page.
The second part of the code example is the source code for the two custom WebPart controls. For the code example to run, you must compile this source code. You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. For a walkthrough that demonstrates both methods of compiling, see Walkthrough: Developing and Using a Custom Web Server Control.
The third part of the example is the Web page that contains the DeclarativeCatalogPart control. Notice that the Button1_Click method calls the GetAvailableWebPartDescriptions method, obtains the descriptions of the WebPart controls in the catalog, and writes out the details to a label.
When you load the page in a browser, select Catalog Mode in the Display Mode drop-down list control to switch to catalog mode. In catalog mode, you can see the controls that are available to be added to the page. You can click the Display WebPart descriptions button to write the details about the controls in the catalog to the label.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.