Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 2.0
 CloseVerb Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework Class Library
WebPartZoneBase.CloseVerb Property

Note: This property is new in the .NET Framework version 2.0.

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

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

Visual Basic (Declaration)
Public Overridable ReadOnly Property CloseVerb As WebPartVerb
Visual Basic (Usage)
Dim instance As WebPartZoneBase
Dim value As WebPartVerb

value = instance.CloseVerb
C#
public virtual WebPartVerb CloseVerb { get; }
C++
public:
virtual property WebPartVerb^ CloseVerb {
    WebPartVerb^ get ();
}
J#
/** @property */
public WebPartVerb get_CloseVerb ()
JScript
public function get CloseVerb () : WebPartVerb

Property Value

A WebPartVerb that enables end users to close WebPart controls.

The close verb referenced by the CloseVerb property appears in the verbs menu of each WebPart control in a zone.

Closing a control removes it from interaction on a page, although if developers provide the appropriate user interface (UI), such as a CatalogZone zone that contains a PageCatalogPart control, a user can switch the page into CatalogDisplayMode and add a previously closed instance of a control back to the page.

The following code example demonstrates the use of the CloseVerb 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 help verb is enabled or disabled.

Visual Basic
Protected Sub CheckBoxList1_SelectedItemIndexChanged(ByVal sender As [Object], ByVal e As EventArgs)
  Dim item As ListItem
  For Each item In CheckBoxList1.Items
    Dim theVerb As WebPartVerb
    Select Case item.Value
      Case "close"
        theVerb = WebPartZone1.CloseVerb
      Case "export"
        theVerb = WebPartZone1.ExportVerb
      Case "delete"
        theVerb = WebPartZone1.DeleteVerb
      Case "minimize"
        theVerb = WebPartZone1.MinimizeVerb
      Case "restore"
        theVerb = WebPartZone1.RestoreVerb
      Case Else
        theVerb = Nothing
    End Select

    If item.Selected Then
      theVerb.Enabled = True
    Else
      theVerb.Enabled = False
    End If
  Next item

End Sub
C#
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 UI. Notice that the declarative <CloseVerb> element in the zone sets the specific text that represents the close verb in the verbs menu for the WebPart control.

Visual Basic
<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>
C#
<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>

Notice also that, because the underlying custom WebPart control--named TextDisplayWebPart-- used in the code example sets the AllowClose property to false in its constructor, the <aspSample:TextDisplayPart> element in the catalog must set the AllowClose property to true, so that the control can be closed in the following code example.

Visual Basic
<asp:CatalogZone ID="CatalogZone1" Runat="server">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      Runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          width="350px" 
          AllowClose="true"
          ExportMode="All"
          HelpMode="Modal"
          HelpUrl="TextWebPartHelp.htm" />            
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" />
  </ZoneTemplate>
</asp:CatalogZone>
C#
<asp:CatalogZone ID="CatalogZone1" Runat="server">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      Runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          width="350px" 
          AllowClose="true"
          ExportMode="All"
          HelpMode="Modal"
          HelpUrl="TextWebPartHelp.htm" />            
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" />
  </ZoneTemplate>
</asp:CatalogZone>

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 close verb, and you can click the Close WebPart verb in the verbs menu to close the control. After you close the control, if you return the page to catalog display mode, you can click the Page Catalog, select the original instance of the TextDisplayWebPart control that you closed, and reopen it on the page.

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

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

.NET Framework

Supported in: 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker