CatalogZoneBase.CloseVerb 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 WebPartVerb 物件的參考,該物件可讓使用者關閉目錄使用者介面 (UI),並讓頁面返回標準瀏覽模式。
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,可以讓使用者關閉 Web 網頁上的目錄 UI。
- 屬性
範例
下列程式碼範例示範如何以宣告方式和以程式設計方式存取 CloseVerb 屬性。 如需執行範例所需的完整程式碼,請參閱類別概觀的 CatalogZoneBase 範例一節。
程式碼範例的第一個部分示範如何在網頁中以宣告方式存取 CloseVerb 屬性。 這個範例會 Description 自訂動詞命令的屬性。
<asp:CatalogZone ID="CatalogZone1" runat="server"
EmptyZoneText="No controls are in the zone."
HeaderText="My Web Parts Catalog"
InstructionText="Add Web Parts controls to the zone."
PartLinkStyle-Font-Italic="true"
SelectedPartLinkStyle-Font-Bold="true"
SelectTargetZoneText="Select zone"
AddVerb-Text="Add Control"
CloseVerb-Description="Close and return to browse mode."
SelectedCatalogPartID="Currently Selected CatalogPart ID.">
<ZoneTemplate>
<asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1"
runat="server">
<WebPartsTemplate>
<aspSample:TextDisplayWebPart
runat="server"
id="textwebpart"
title = "Text Content WebPart"
ExportMode="All"/>
<asp:Calendar id="calendar1" runat="server"
Title="My Calendar" />
</WebPartsTemplate>
</asp:DeclarativeCatalogPart>
<asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
<asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" />
</ZoneTemplate>
</asp:CatalogZone>
<hr />
<asp:CatalogZone ID="CatalogZone2" runat="server"
BorderWidth="2"
HeaderText="My Empty CatalogZone"
EmptyZoneText="No controls are in the zone." />
<asp:CatalogZone ID="CatalogZone1" runat="server"
EmptyZoneText="No controls are in the zone."
HeaderText="My Web Parts Catalog"
InstructionText="Add Web Parts controls to the zone."
PartLinkStyle-Font-Italic="true"
SelectedPartLinkStyle-Font-Bold="true"
SelectTargetZoneText="Select zone"
AddVerb-Text="Add Control"
CloseVerb-Description="Close and return to browse mode."
SelectedCatalogPartID="Currently Selected CatalogPart ID.">
<ZoneTemplate>
<asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1"
runat="server">
<WebPartsTemplate>
<aspSample:TextDisplayWebPart
runat="server"
id="textwebpart"
title = "Text Content WebPart"
ExportMode="All"/>
<asp:Calendar id="calendar1" runat="server"
Title="My Calendar" />
</WebPartsTemplate>
</asp:DeclarativeCatalogPart>
<asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
<asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" />
</ZoneTemplate>
</asp:CatalogZone>
<hr />
<asp:CatalogZone ID="CatalogZone2" runat="server"
BorderWidth="2"
HeaderText="My Empty CatalogZone"
EmptyZoneText="No controls are in the zone." />
此範例的第二個部分示範如何使用切換按鈕來啟用或停用屬性,以程式設計方式存取 CloseVerb 屬性。
protected void Button1_Click(object sender, EventArgs e)
{
if (CatalogZone1.AddVerb.Enabled)
{
CatalogZone1.AddVerb.Enabled = false;
CatalogZone1.CloseVerb.Enabled = false;
}
else
{
CatalogZone1.AddVerb.Enabled = true;
CatalogZone1.CloseVerb.Enabled = true;
}
}
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As EventArgs)
If CatalogZone1.AddVerb.Enabled Then
CatalogZone1.AddVerb.Enabled = False
CatalogZone1.CloseVerb.Enabled = False
Else
CatalogZone1.AddVerb.Enabled = True
CatalogZone1.CloseVerb.Enabled = True
End If
End Sub
當您在瀏覽器中載入頁面時,您可以從下拉式清單中選取 [ 目錄 ],以切換至目錄顯示模式。 當目錄可見時,將滑鼠指標放在 [ 關閉 ] 按鈕上方,即可在工具提示中看到其描述文字。 您也可以按一下 [ 啟用] 或 [停用動詞] 按鈕,示範您可以以程式設計方式存取關閉動詞。
備註
關閉動詞是由 CloseVerb 衍生自 類別之 CatalogZoneBase 控制項上的 屬性所參考。
使用者可以按一下區域頁尾中的關閉動詞。 當使用者按一下關閉動詞時,會忽略使用者選取的任何 CatalogPart 控制項、目錄 UI 會關閉,而頁面會返回正常瀏覽模式。
關閉動詞是區域層級控制項,這表示其動作會套用至整個區域的層級。 當使用者按一下關閉動詞時,會忽略已選取但未新增至頁面的任何控制項、關閉目錄,且頁面會返回瀏覽模式。