CatalogZoneBase.CatalogParts Property


Gets a collection of all the CatalogPart controls contained in a CatalogZoneBase zone.

Namespace:   System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

public CatalogPartCollection CatalogParts { get; }

Property Value

Type: System.Web.UI.WebControls.WebParts.CatalogPartCollection

A CatalogPartCollection that contains all the individual CatalogPart controls in a zone.

Exception Condition

A CatalogPart being added to the collection did not have a value assigned to its ID property.

The CatalogParts property provides a reference to a collection of all the CatalogPart controls in the zone. It references both the CatalogPart controls provided with the Web Parts control set, and any custom CatalogPart controls that are added to the zone.

The collection is initially created when another method accesses the CatalogParts property, and the property calls the CreateCatalogParts method.


Note that any CatalogPart that is added to the collection of CatalogPart controls in an implementation of the CreateCatalogParts method must have a value assigned to its ID property, otherwise an exception will be thrown when the collection is assigned to the CatalogParts property.

The following code example demonstrates how to access the CatalogParts property programmatically. For the full code required to run the example, see the Example section of the CatalogZoneBase class overview.

The code example shows how to access the CatalogParts property, iterate through the collection, and list the IDs of all the CatalogPart controls in the zone.

protected void Button2_Click(object sender, EventArgs e)
  Label1.Text = "<h3>CatalogPart List</h3>";
  foreach(CatalogPart part in CatalogZone1.CatalogParts)
    Label1.Text += part.ID + "<br />";

When you load the page in a browser, you can select Catalog from the drop-down list to switch to catalog display mode. When the catalog is visible, you can click the List CatalogParts button to demonstrate how the CatalogParts property can be accessed.

.NET Framework
Available since 2.0
Return to top