CatalogZoneBase.AddVerb Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a reference to a WebPartVerb object that enables end users to add controls from a catalog to a Web Parts page.

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

[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
public virtual WebPartVerb AddVerb { get; }

Property Value

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

A WebPartVerb that enables end users to add controls from the catalog to a Web page.

The add verb is referenced by the AddVerb property on a control derived from the CatalogZoneBase class. The add verb adds a control that an end user has selected in the catalog to a Web page. Typically, the add verb appears in the user interface (UI) as a Button control, although it can also be a link or an image.

The add verb is a zone-level control, meaning that although there might be several CatalogPart controls in the catalog, the add verb applies to all the controls selected by the user and adds them to the selected zone.

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

The first part of the code example shows how to access the ApplyVerb property declaratively in a Web page. This example customizes the text for the verb.

<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." />

The second part of the example shows how to access the AddVerb property programmatically, by using a toggle button to enable or disable it.

protected void Button1_Click(object sender, EventArgs e)
{
  if (CatalogZone1.AddVerb.Enabled)
  {
    CatalogZone1.AddVerb.Enabled = false;
    CatalogZone1.CloseVerb.Enabled = false;
  }
  else
  {
    CatalogZone1.AddVerb.Enabled = true;
    CatalogZone1.CloseVerb.Enabled = true;
  }
}

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 examine the customized text on the Button control for the add verb, and you can click the Enable or Disable Verbs button to demonstrate that you can access the apply verb programmatically.

.NET Framework
Available since 2.0
Return to top
Show: