15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Web Parts ❘ 1211<br />

The use of Web Parts is a complex topic, <strong>and</strong> this section does not describe all available functionality or list<br />

all the properties <strong>and</strong> methods that the Web Part components supply. However, you do see enough to get a<br />

flavor of Web Parts <strong>and</strong> to underst<strong>and</strong> the basic functionality that is possible.<br />

Web Parts application Components<br />

The Web Parts section of the toolbox contains 13 controls, as described in the following table. The table<br />

also introduces some of the key concepts for Web Parts pages.<br />

ConTrol<br />

WebPartManager<br />

ProxyWebPartManager<br />

WebPartZone<br />

CatalogZone<br />

DeclarativeCatalogPart<br />

PageCatalogPart<br />

ImportCatalogPart<br />

EditorZone<br />

AppearanceEditorPart<br />

desCriPTion<br />

Every page that uses Web Parts must have one (<strong>and</strong> only one) instance of<br />

the WebPartManager control. You can place it on a master page if you wish,<br />

although if you do you should use the master page only when you want to use<br />

Web Parts on a page. This control is responsible for the majority of Web Parts<br />

functionality, which it supplies without much intervention. You may not need<br />

to do much more than place it on a web page, depending on the functionality<br />

you require. For more advanced functionality, you can use the large number<br />

of properties <strong>and</strong> events that this control exposes.<br />

If you place the WebPartManager control on a master page, it can be difficult<br />

to configure it on individual pages — <strong>and</strong> impossible to do so declaratively.<br />

This is particularly relevant for the definition of static connections between<br />

Web Parts. The ProxyWebPartManager control enables you to define static<br />

connections declaratively on a web page, which circumvents the problem of<br />

not being able to have two WebPartManager controls on the same page.<br />

The WebPartZone control is used to define a region of a page that can<br />

contain Web Parts. You will typically use more than one of these controls on<br />

a page. For example, you might use three of them in a three-column layout<br />

on a page. Users can move Web Parts between WebPartZone regions or<br />

reposition them within a single WebPartZone.<br />

The CatalogZone control enables users to add Web Parts to a page. This<br />

control contains controls that derive from CatalogPart, of which three are<br />

supplied for you — the next three entries in this table describe these controls.<br />

Whether the CatalogZone control <strong>and</strong> the controls it contains are visible<br />

depends on the current display mode set by WebPartManager.<br />

The DeclarativeCatalogPart control enables you to define Web Part<br />

controls inline. These controls will then be available to the user through the<br />

CatalogZone control.<br />

Users can remove (close) Web Parts that are displayed on a page. To retrieve<br />

them, the PageCatalogPart control provides a list of closed Web Parts that<br />

can be replaced on the page.<br />

The ImportCatalogPart control enables Web Parts that have been<br />

exported from a page to be imported to another page through the<br />

CatalogPart interface.<br />

The EditorZone control contains controls that enable users to edit various<br />

aspects of Web Part display <strong>and</strong> behavior, depending on what controls it<br />

contains. It can contain controls that derive from EditorPart, including the<br />

four that are listed in the next four rows of this table. As with CatalogZone,<br />

the display of this control depends on the current display mode.<br />

This control enables users to modify the look <strong>and</strong> size of Web Part controls, as<br />

well as to hide them.<br />

continues<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!