EditorZone.ZoneTemplate 屬性

定義

提供樣板,以頁面保存格式將子控制項包含在 EditorZone 控制項之中。

public:
 virtual property System::Web::UI::ITemplate ^ ZoneTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.WebParts.EditorZone))]
[System.Web.UI.TemplateInstance(System.Web.UI.TemplateInstance.Single)]
public virtual System.Web.UI.ITemplate ZoneTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.WebParts.EditorZone))>]
[<System.Web.UI.TemplateInstance(System.Web.UI.TemplateInstance.Single)>]
member this.ZoneTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property ZoneTemplate As ITemplate

屬性值

ITemplate 區域樣板,做為區域中子控制項的容器。

屬性

範例

下列程式碼範例示範屬性的 ZoneTemplate 宣告式用法。 範例的完整程式碼位於類別概觀的 EditorZone Example 區段中。

程式碼範例示範控制項如何在 EditorPart 控制項的 元素內 <zonetemplate>EditorZone 放置控制項。

<asp:EditorZone ID="EditorZone1" runat="server" >
  <VerbStyle Font-Italic="true" />
  <EditUIStyle BackColor="lightgray" />
  <PartChromeStyle BorderWidth="1" />
  <LabelStyle Font-Bold="true" />
  <CancelVerb Text="Cancel Changes" />
  <ZoneTemplate>
    <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
      runat="server" />
    <asp:LayoutEditorPart ID="LayoutEditorPart1" 
      runat="server" />
  </ZoneTemplate>
</asp:EditorZone>
<asp:EditorZone ID="EditorZone1" runat="server" >
  <VerbStyle Font-Italic="true" />
  <EditUIStyle BackColor="lightgray" />
  <PartChromeStyle BorderWidth="1" />
  <LabelStyle Font-Bold="true" />
  <CancelVerb Text="Cancel Changes" />
  <ZoneTemplate>
    <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
      runat="server" />
    <asp:LayoutEditorPart ID="LayoutEditorPart1" 
      runat="server" />
  </ZoneTemplate>
</asp:EditorZone>

當您在瀏覽器中載入頁面時,您可以在下拉式清單中選取 [ 編輯模式 ],以切換至編輯模式。 若要顯示編輯使用者介面 (UI) ,您可以按一下動詞功能表, (兩個控制項的標題列中的向下箭號) ,然後按一下 [ 編輯 ] 編輯控制項。 透過編輯 UI 可見,您可以看到元素內 <zonetemplate> 所宣告的數 EditorPart 個控制項。

備註

屬性 ZoneTemplate 是 類別與基 EditorZoneBase 類之間的 EditorZone 主要差異。 藉由新增區域範本的支援,類別 EditorZone 可讓頁面開發人員將子 EditorPart 控制項放在網頁的宣告式標記中 EditorZone 。 區域範本可作為子控制項的容器。

注意

屬性的 ZoneTemplate set 存取子會呼叫 InvalidateEditorParts 方法,以強制重新建立範本中所宣告的 EditorPart 控制項集合。 這會導致辨識範本內容中的任何變更。

若要在控制項內 EditorZone 以宣告方式使用區域範本,您可以新增一對 <zonetemplate> 標記,並在標記之間參考 EditorPart 控制項。 因此,每個控制項實例只會轉譯一個 EditorZone 區域範本 (,因此沒有理由將多個 <zonetemplate> 元素新增至 EditorZone 控制項) 。 此外,控制項的區域範本只能包含衍生自 EditorPart 類別的 EditorZone 元件控制項。

適用於

另請參閱