CatalogZoneBase.AddVerb 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 WebPartVerb 物件的參考,這個物件可讓使用者從目錄加入控制項至 Web 組件頁面。
public:
virtual property System::Web::UI::WebControls::WebParts::WebPartVerb ^ AddVerb { System::Web::UI::WebControls::WebParts::WebPartVerb ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public virtual System.Web.UI.WebControls.WebParts.WebPartVerb AddVerb { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.AddVerb : System.Web.UI.WebControls.WebParts.WebPartVerb
Public Overridable ReadOnly Property AddVerb As WebPartVerb
屬性值
WebPartVerb,可以讓使用者從目錄加入控制項至 Web 網頁。
- 屬性
範例
下列程式碼範例示範如何以宣告方式和程式設計方式存取 AddVerb 屬性。 如需執行範例所需的完整程式碼,請參閱類別概觀的 CatalogZoneBase 範例一節。
程式碼範例的第一個部分示範如何在網頁中以宣告方式存取 ApplyVerb 屬性。 本範例會自訂動詞的文字。
<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." />
範例的第二個部分示範如何使用切換按鈕來啟用或停用屬性,以程式設計方式存取 AddVerb 屬性。
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
當您在瀏覽器中載入頁面時,您可以從下拉式清單中選取 [目錄 ],以切換至目錄顯示模式。 當目錄可見時,您可以檢查控制項上 Button 新增動詞的自訂文字,然後按一下 [啟用] 或 [停用動詞 ] 按鈕,以示範您可以以程式設計方式存取套用動詞。
備註
附加動詞是由 AddVerb 衍生自 CatalogZoneBase 類別之控制項上的 屬性所參考。 新增動詞會新增使用者在目錄中選取的控制項至網頁。 一般而言,新增動詞會出現在使用者介面 (UI) 做為 Button 控制項,不過也可以是連結或影像。
add 動詞是區域層級控制項,這表示雖然目錄中可能有數 CatalogPart 個控制項,但 add 動詞會套用至使用者選取的所有控制項,並將其新增至選取的區域。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應