WebPartZoneBase.DeleteVerb 属性

定义

获取对 WebPartVerb 对象的引用,该对象使最终用户能够删除区域中的 WebPart 控件。

public:
 virtual property System::Web::UI::WebControls::WebParts::WebPartVerb ^ DeleteVerb { System::Web::UI::WebControls::WebParts::WebPartVerb ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public virtual System.Web.UI.WebControls.WebParts.WebPartVerb DeleteVerb { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.DeleteVerb : System.Web.UI.WebControls.WebParts.WebPartVerb
Public Overridable ReadOnly Property DeleteVerb As WebPartVerb

属性值

使最终用户能够删除 WebPartVerb 控件的 WebPart

属性

示例

下面的代码示例演示如何在 DeleteVerb 控件上使用 WebPartZone 属性。 要使代码示例正常工作,需要属性的 Example 节 HelpVerb 中的所有代码。

代码示例的以下部分来自分部类,包含用于切换删除谓词是启用或禁用的代码。

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;
  }
}
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

代码示例的另一部分是承载自定义控件的网页,其中包含用户界面 (UI) 。 请注意,区域中的声明性 <DeleteVerb> 元素设置特定文本,该文本代表控件的谓词下拉菜单 WebPart 中的删除谓词。

<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>
<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>

在浏览器中加载页面后,将页面切换到目录显示模式,并将控件 TextDisplayWebPart 添加到页面。 可以使用复选框在控件上 TextDisplayWebPart 启用和禁用删除谓词,但谓词仅在页面处于目录或设计显示模式时显示在菜单上。 如果单击菜单上的 “删除 WebPart” 谓词,该控件将被永久删除,并且无法将已删除的实例添加回页面。 但是,可以将页面返回到目录显示模式,并添加控件的新实例 TextDisplayWebPart

注解

属性引用的 DeleteVerb 删除谓词显示在区域中每个动态 WebPart 控件的标题栏中的谓词下拉菜单中。 删除谓词在网页) 的标记中声明的静态控件 (上不可用。 仅当页面处于允许更改页面布局(如 CatalogDisplayModeDesignDisplayMode)的显示模式时,谓词才会显示在谓词菜单中。

删除控件会从页面永久删除该控件的实例。 与关闭的控件不同,控件的已删除实例永远无法添加回页。 当用户删除控件,然后将页面 CatalogDisplayMode切换到 时,如果 CatalogZone 区域包含控件 PageCatalogPart ,则已删除的控件实例在它中不可用。 如果控件在目录中可用,但已删除的实例已被永久删除,则用户可以添加控件的新实例。

适用于

另请参阅