WebPartZoneBase.ExportVerb 属性

定义

获取对 WebPartVerb 对象的引用,该对象使最终用户能够导出区域中每个 WebPart 控件的 XML 定义文件。

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

属性值

使最终用户能够导出 WebPartVerb 控件的定义文件的 WebPart

属性

示例

下面的代码示例演示如何在 ExportVerb 控件上使用 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) 的网页。 请注意,区域中的声明性 <ExportVerb> 元素设置特定文本,该文本表示控件的谓词下拉菜单 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>

最后请注意,在下面的代码示例中,元素上的<asp:TextDisplayWebPart>声明性ExportMode属性值设置为 值All,这意味着将导出控件上的所有可导出属性值。

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

在浏览器中加载页面后,将页面切换到目录显示模式,并将控件 TextDisplayWebPart 添加到页面。 可以使用复选框在控件上 TextDisplayWebPart 启用和禁用导出谓词。 如果单击导出谓词,系统会提示输入本地路径以保存控件的定义文件。

注解

属性引用的 ExportVerb 导出谓词显示在区域中每个 WebPart 控件的标题栏中的谓词下拉菜单中。 谓词在所有页面显示模式下都显示在谓词菜单中。

若要使用户能够导出控件的定义文件 WebPart ,还必须将 控件上的 属性设置为 ExportMode 其默认值以外的其他值,即 None

适用于

另请参阅