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

一个 ITemplate 区域模板,作为区域中子控件的容器。

属性

示例

下面的代码示例演示属性 ZoneTemplate 的声明性用法。 本示例的完整代码位于类概述的 EditorZone “示例”部分中。

该代码示例演示如何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类使页面开发人员能够在网页的声明性标记中的控件内EditorZone放置子EditorPart控件。 区域模板充当子控件的容器。

备注

属性的 set 访问器 ZoneTemplate 调用 InvalidateEditorParts 该方法,该方法强制重新创建模板中声明的 EditorPart 控件集合。 这会导致识别模板内容的任何更改。

若要在控件中 EditorZone 以声明方式使用区域模板,请在标记之间添加一对 <zonetemplate> 标记和引用 EditorPart 控件。 因此,每个控件实例只呈现一个 EditorZone 区域模板 (,因此没有理由向控件) 添加多个 <zonetemplate> 元素 EditorZone 。 此外,控件的区域模板 EditorZone 只能包含派生自类的 EditorPart 部件控件。

适用于

另请参阅