Export (0) Print
Expand All

WebPartZoneBase.DeleteVerb Property

Gets a reference to a WebPartVerb object that enables end users to delete the WebPart controls in a zone.

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

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

Property Value

Type: System.Web.UI.WebControls.WebParts.WebPartVerb
A WebPartVerb that enables end users to delete WebPart controls.

The delete verb referenced by the DeleteVerb property appears in the verbs drop-down menu in the title bar of each dynamic WebPart control in a zone. The delete verb is not available on static controls (controls declared in the markup of the Web page). The verb appears in the verbs menu only when the page is in a display mode that enables you to change the page layout, such as CatalogDisplayMode or DesignDisplayMode.

Deleting a control permanently removes the instance of that control from a page. Unlike a closed control, a deleted instance of a control can never be added back to a page. When a user deletes a control, and then switches a page into CatalogDisplayMode, if the CatalogZone zone contains a PageCatalogPart control, the deleted control instance is not available in it. The user can add a new instance of a control, if the control is available in the catalog, but the deleted instance has been permanently removed.

The following code example demonstrates the use of the DeleteVerb property on a WebPartZone control. For the code example to work, you need all the code from the Example section of the HelpVerb property.

The following part of the code example is from the partial class, and contains the code that toggles whether the delete verb is enabled or disabled.

protected void CheckBoxList1_SelectedItemIndexChanged(Object sender, EventArgs e)
{
  foreach (ListItem item in CheckBoxList1.Items)
  {
    WebPartVerb theVerb;
    switch (item.Value)
    {
      case "close":
        theVerb = WebPartZone1.CloseVerb;
        break;
      case "export":
        theVerb = WebPartZone1.ExportVerb;
        break;
      case "delete":
        theVerb = WebPartZone1.DeleteVerb;
        break;
      case "minimize":
        theVerb = WebPartZone1.MinimizeVerb;
        break;
      case "restore":
        theVerb = WebPartZone1.RestoreVerb;
        break;
      default:
        theVerb = null;
        break;
    }

    if (item.Selected)
      theVerb.Enabled = true;
    else
      theVerb.Enabled = false;
  }
}

The other part of the code example is the Web page that hosts the custom control and contains the user interface (UI). Notice that the declarative <DeleteVerb> element in the zone sets the specific text that represents the delete verb in the verbs drop-down menu for the WebPart control.

<asp:WebPartZone ID="WebPartZone1" Runat="server">
  <CloseVerb Text="Close WebPart" />
  <HelpVerb Text="View Help" />
  <ExportVerb Text="Export WebPart Definition" />
  <DeleteVerb Text ="Delete WebPart" />
  <MinimizeVerb Description="Minimize the control" />
  <RestoreVerb Description="Restore the control" />
  <ZoneTemplate>
  </ZoneTemplate>  
</asp:WebPartZone>

After you load the page in a browser, switch the page into catalog display mode, and add the TextDisplayWebPart control to the page. You can use the check boxes to enable and disable the delete verb on the TextDisplayWebPart control, but the verb appears on the menu only while the page is in catalog or design display mode. If you click the Delete WebPart verb on the menu, the control is permanently deleted, and the deleted instance cannot be added back to the page. However, you can return the page to catalog display mode, and add a new instance of the TextDisplayWebPart control.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft