Display Modes and Web Parts

 

Display Modes and Web Parts

Recall that the event handler for the drop-down list for Default.aspx in the WebParts project changed the DisplayMode property of the WebPartManager1 object. The DisplayMode property must be one of the WebPartDisplayMode enumerations, as outlined in Table 4-3.

Table 4-3: WebPartDisplayMode Enumerations

DisplayMode Property

Description

BrowseDisplayMode

Displays Web Parts for normal, end user use. This is the default mode.

DesignDisplayMode

Displays the Web Part zone user interface (UI), enabling users to drag and drop Web Part components to change the layout of the page.

EditDisplayMode

Displays special editing UI elements and allows end users to edit the controls on the page.

CatalogDisplayMode

Displays a special catalog UI to allow end users to add and remove page controls.

ConnectDisplayMode

Displays a special connections UI to allow end users to connect Web Part controls.

Browse, Design, and Catalog are the three display modes you will use most. The BrowseDisplayMode enumeration can be seen in Figure 4-1, and the DesignDisplayMode enumeration can be seen in Figure 4-2 and Figure 4-3. To use the CatalogDisplayMode enumeration, you must first close one of the Web Parts on the page. In Figure 4-6, the menu for one of the Web Parts appears on the Default.aspx page.

image from book
Figure 4-6: The menu that allows you to close or minimize a Web Part

When you click Close, the page appears as shown in Figure 4-7.

image from book
Figure 4-7: Default.aspx after one Web Part is closed

The first thing I noticed when I first played with Web Parts is that when you close a Web Part, it stays closed! The state of the page is saved, even if you have not logged in to the site. This is known, rather oddly, as anonymous personalization.

To get the closed Web Part back, you must enter Catalog mode. In Default.aspx, select Catalog from the drop-down list, and the page appears as shown in Figure 4-8.

image from book
Figure 4-8: Default.aspx in Catalog mode after one Web Part is closed

The interesting portion of the page is the Page Catalog inside of the Catalog Zone. Untitled [1] is in the list of Web Parts in the catalog. When you select the check box next to Untitled [1] and click Add, the Web Part is added to the selected zone, WebPartZone1, as shown in Figure 4-9.

image from book
Figure 4-9: Default.aspx in Catalog mode after adding the previously closed Web Part

 


Programming Microsoft Web Forms
Programming Microsoft Web Forms (Pro Developer)
ISBN: 0735621799
EAN: 2147483647
Year: 2005
Pages: 70
Authors: Douglas J. Reilly
BUY ON AMAZON

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