ערוך

שתף באמצעות


CatalogZoneBase.SelectedCatalogPartID Property

Definition

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

public:
 property System::String ^ SelectedCatalogPartID { System::String ^ get(); void set(System::String ^ value); };
[System.Web.UI.Themeable(false)]
public string SelectedCatalogPartID { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.SelectedCatalogPartID : string with get, set
Public Property SelectedCatalogPartID As String

Property Value

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

Attributes

Examples

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."
  PartLinkStyle-Font-Italic="true"
  SelectedPartLinkStyle-Font-Bold="true"
  SelectTargetZoneText="Select zone"
  AddVerb-Text="Add Control"
  CloseVerb-Description="Close and return to browse mode." 
  SelectedCatalogPartID="Currently Selected CatalogPart ID.">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          ExportMode="All"/>  
        <asp:Calendar id="calendar1" runat="server" 
          Title="My Calendar" />               
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
    <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" /> 
  </ZoneTemplate>
</asp:CatalogZone>
<hr />
<asp:CatalogZone ID="CatalogZone2" runat="server"
  BorderWidth="2"
  HeaderText="My Empty CatalogZone"
  EmptyZoneText="No controls are in the zone." />
<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."
  PartLinkStyle-Font-Italic="true"
  SelectedPartLinkStyle-Font-Bold="true"
  SelectTargetZoneText="Select zone"
  AddVerb-Text="Add Control"
  CloseVerb-Description="Close and return to browse mode." 
  SelectedCatalogPartID="Currently Selected CatalogPart ID.">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          ExportMode="All"/>  
        <asp:Calendar id="calendar1" runat="server" 
          Title="My Calendar" />               
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
    <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" /> 
  </ZoneTemplate>
</asp:CatalogZone>
<hr />
<asp:CatalogZone ID="CatalogZone2" runat="server"
  BorderWidth="2"
  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;
}
Protected Sub Button4_Click(ByVal sender As Object, _
  ByVal e As EventArgs)
  Label1.Text = CatalogZone1.SelectedCatalogPartID
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, 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.

Remarks

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.

Applies to

See also