共用方式為


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>

最後,請注意,在下列程式代碼範例中,專案的宣告式 ExportMode 屬性值 <asp:TextDisplayWebPart> 會設定為 值 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

適用於

另請參閱