Redigera

Dela via


CatalogZoneBase.CatalogParts Property

Definition

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

public:
 property System::Web::UI::WebControls::WebParts::CatalogPartCollection ^ CatalogParts { System::Web::UI::WebControls::WebParts::CatalogPartCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.WebControls.WebParts.CatalogPartCollection CatalogParts { get; }
[<System.ComponentModel.Browsable(false)>]
member this.CatalogParts : System.Web.UI.WebControls.WebParts.CatalogPartCollection
Public ReadOnly Property CatalogParts As CatalogPartCollection

Property Value

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

Attributes

Exceptions

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

Examples

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 />";
  }
}
Protected Sub Button2_Click(ByVal sender As Object, _
  ByVal e As EventArgs)
  Label1.Text = "<h3>CatalogPart List</h3>"
  Dim part As CatalogPart
  For Each part In CatalogZone1.CatalogParts
    Label1.Text += part.ID + "<br />"
  Next part

End Sub

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.

Remarks

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

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.

Applies to

See also