WebPartZoneBase.CloseVerb 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 WebPartVerb 物件的參考,這個物件可讓使用者關閉區域中的 WebPart 控制項。
public:
virtual property System::Web::UI::WebControls::WebParts::WebPartVerb ^ CloseVerb { System::Web::UI::WebControls::WebParts::WebPartVerb ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public virtual System.Web.UI.WebControls.WebParts.WebPartVerb CloseVerb { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.CloseVerb : System.Web.UI.WebControls.WebParts.WebPartVerb
Public Overridable ReadOnly Property CloseVerb As WebPartVerb
屬性值
WebPartVerb,可讓使用者關閉 WebPart 控制項。
- 屬性
範例
下列程式代碼範例示範 CloseVerb 在控件上使用 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的網頁。 請注意,區域中的宣告式 <CloseVerb>
元素會設定特定文字,代表控件動詞功能表 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>
另請注意,由於程式代碼範例中的基礎自定義WebPart控件命名TextDisplayWebPart
為 -- 在建構函式中將 屬性false
設定AllowClose為 ,所以目錄中的 元素必須將 屬性true
設定AllowClose為 ,<aspSample:TextDisplayPart>
以便在下列程式代碼範例中關閉控件。
<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
至頁面。 您可以使用複選框來啟用和停用關閉動詞,而且您可以按下動詞選單中的 [關閉 WebPart ] 動詞來關閉控件。 關閉控制項之後,如果您將頁面傳回目錄顯示模式,您可以按下 [頁面目錄],選取您關閉之 TextDisplayWebPart
控件的原始實例,然後在頁面上重新開啟它。
備註
屬性所參考的 CloseVerb 關閉動詞會出現在區域中每個 WebPart 控件的動詞功能表。
關閉控件會從頁面上的互動中移除它,雖然如果開發人員提供適當的使用者介面 (UI) ,例如 CatalogZone 包含 PageCatalogPart 控件的區域,使用者可以將頁面 CatalogDisplayMode 切換至 ,並將先前關閉的控件實例新增回頁面。