Catalog Zones


By default, users can remove WebParts from a page by clicking the Close link. The closed WebPart can be added back into a page by using a catalog. The catalog holds two sets of WebParts: those that the user has removed from the page (the Page Catalog) and those that are available for use on the page, but weren't declared within a zone (the Declarative Catalog). A catalog is a zone, and it can be placed anywhere on the page. For example, consider Listing 13.11, which shows a CatalogZone.

Listing 13.11. Declaring a CatalogZone

<asp:CatalogZone  runat="server">   <ZoneTemplate>     <asp:PageCatalogPart  runat="server" />     <asp:DeclarativeCatalogPart        runat="server">       <WebPartsTemplate>         <uc2:canteen  runat="server" Title="Canteen" />         <uc3:stocks  runat="server" Title="Stocks" />         <sample:MSNWeatherWebPart runat="server"            Title="MSN Weather" />       </WebPartsTemplate>     </asp:DeclarativeCatalogPart>   </ZoneTemplate> </asp:CatalogZone>

Within the ZoneTemplate of the CatalogZone, there are two catalog WebParts: the PageCatalogPart and the DeclarativeCatalogPart. The PageCatalogPart shows WebParts that have been removed from the page by the user, and therefore has no other content. The DeclarativeCatalogPart shows the parts that are available but that weren't put on the page when it was designed.

The CatalogZone only appears when the page is placed into catalog mode, which is when the DisplayMode of the WebPartManager is set to WebPartManager.CatalogDisplayMode. Figure 13.8 shows the Catalog Zone in action. On the left, the Page Catalog is selected, showing the WebParts that the user has removed from the pagein this case, the MSN Weather WebPart. On the right, the Declarative Catalog is selected, where there are three WebParts: Canteen, Stocks, and MSN Weather. At the bottom of the Catalog Zone there is a list of zones into which the selected WebParts can be added.

Figure 13.8. Displaying the Catalog of WebParts


One point of interest is that the MSN Weather WebPart appears on both the Page and Declarative catalogs. This is because the WebPart wasn't initially on the page but was added from the Declarative Catalog and later closed. Closing a WebPart is different from deleting it, because closure just adds it to the Page Catalog, whereas deleting the WebPart completely removes it from the page (along with display of an appropriate warning).

Importing and Exporting WebParts

Anotherbut less frequently usedcatalog is the Imported WebPart Catalog, which allows you to import WebPart declarations stored outside of the catalog. You declare an import catalog by use of the ImportCatalogPart, used alongside the PageCatalogPart and DeclarativeCatalogPart:

<asp:ImportCatalogPart  runat="server" />


Selecting the Imported WebPart Catalog (see Figure 13.8) allows you to browse the file system to find exported WebParts. These are XML files with a .WebPart suffix that define the properties of the part such as Title, whether minimizing is allowed, and so on.

Importing and exporting of WebParts is primarily used to copy WebParts between pages.



ASP. NET 2.0 Illustrated
ASP.NET 2.0 Illustrated
ISBN: 0321418344
EAN: 2147483647
Year: 2006
Pages: 147

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net