PageCatalogPart.GetAvailableWebPartDescriptions Method
Assembly: System.Web (in system.web.dll)
public WebPartDescriptionCollection GetAvailableWebPartDescriptions ()
public override function GetAvailableWebPartDescriptions () : WebPartDescriptionCollection
Return Value
A WebPartDescriptionCollection that contains a WebPartDescription for each closed WebPart control in a page 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 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 PageCatalogPart 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 Server Control.
The third part of the example is the Web page that contains the PageCatalogPart control. Notice that the Button1_Click method calls the GetAvailableWebPartDescriptions method, obtains the descriptions of the WebPart controls in the page catalog, and writes 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. Add one or more controls to the page, and then use the Display Mode drop-down list control to return the page to browse mode. Click the verbs menu (the downward arrow) in the title bar of one or more of the controls, and click Close. Return the page to catalog mode, and notice that the control or controls you closed now appear in the page catalog, and are available to be added back to the page. Click the Display WebPart descriptions button to write the details about the controls in the page catalog to the label.
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.