CatalogZoneBase.SelectedCatalogPartID Property


Gets or sets a string as an identifier for the currently selected CatalogPart control in a zone.

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

public string SelectedCatalogPartID { get; set; }

Property Value

Type: System.String

A string that serves as the identifier for the currently selected control. The default is the value of the control's ID property.

The SelectedCatalogPartID property allows you to set an identifier of your choice for the currently selected CatalogPart control. This does not change the control's ID property value, so you can use this property for your own programmatic purposes. For example, if you wanted to always carry out some programmatic action on the currently selected CatalogPart control, this property enables you to access that control through a known value that you set in advance.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

The following code example demonstrates how to use the SelectedCatalogPartID property declaratively and programmatically. For the full code required to run the example, see the Example section of the CatalogZoneBase class overview.

Notice that the first part of the code example declares two <asp:catalogzone> elements, and the first one declares a value for the SelectedCatalogPartID property.

<asp:CatalogZone ID="CatalogZone1" runat="server"
  EmptyZoneText="No controls are in the zone."
  HeaderText="My Web Parts Catalog"
  InstructionText="Add Web Parts controls to the zone."
  SelectTargetZoneText="Select zone"
  AddVerb-Text="Add Control"
  CloseVerb-Description="Close and return to browse mode." 
  SelectedCatalogPartID="Currently Selected CatalogPart ID.">
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
          title = "Text Content WebPart" 
        <asp:Calendar id="calendar1" runat="server" 
          Title="My Calendar" />               
    <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
    <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" /> 
<hr />
<asp:CatalogZone ID="CatalogZone2" runat="server"
  HeaderText="My Empty CatalogZone"
  EmptyZoneText="No controls are in the zone." />

In the second part of the code example, the text value for the SelectedCatalogPartID property of the currently selected control is displayed.

protected void Button4_Click(object sender, EventArgs e)
  Label1.Text = CatalogZone1.SelectedCatalogPartID;

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, click one of the links to a CatalogPart control to select it. Then click the Show Selected CatalogPart ID button to display the property value. Notice that the value of the property is the value that was set declaratively for the zone. If you select the other CatalogPart controls in the zone, the same value becomes the value of the SelectedCatalogPartID property for each control when it is selected. If you do not set the value of the SelectedCatalogPartID property, the default value is always the value of the ID property for the currently selected control.

.NET Framework
Available since 2.0
Return to top