EditorZone.ZoneTemplate 属性

定义

提供模板来以页持久性格式包含 EditorZone 控件中的子控件。Provides a template to contain child controls within an EditorZone control in page persistence format.

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 区域模板,作为区域中子控件的容器。An ITemplate zone template that acts as a container for child controls in the zone.

属性

示例

下面的代码示例演示了属性的声明性用法 ZoneTemplateThe following code example demonstrates declarative use of the ZoneTemplate property. 该示例的完整代码位于类概述的 "示例" 部分 EditorZoneThe full code for the example is found in the Example section of the EditorZone class overview.

此代码示例演示如何 EditorPart 将控件放置在 <zonetemplate> 控件中的元素内 EditorZoneThe code example demonstrates how EditorPart controls can be placed within a <zonetemplate> element in an EditorZone control.

<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>

当你在浏览器中加载页面时,可以在下拉列表中选择 " 编辑模式 " 以切换到编辑模式。When you load the page in a browser, you can select Edit Mode in the drop-down list to switch to edit mode. 若要显示编辑用户界面 (UI ") ,可以在两个控件之一的标题栏中 (向下箭头) 单击谓词菜单,然后单击" 编辑 "以编辑控件。To display the editing user interface (UI), you can click the verbs menu (the downward arrow) in the title bar of one of the two controls, and click Edit to edit the control. 编辑 UI 可见后,可以看到在 EditorPart 元素中声明的多个控件 <zonetemplate>With the editing UI visible, you can see the several EditorPart controls that are declared within the <zonetemplate> element.

注解

ZoneTemplate属性是类和基类之间的主要区别 EditorZone EditorZoneBaseThe ZoneTemplate property is the key difference between the EditorZone class and the base EditorZoneBase class. 通过添加对区域模板的支持, EditorZone 页面开发人员可以 EditorPart 在网页 EditorZone 的声明性标记中将子控件置于控件中。By adding support for a zone template, the EditorZone class enables page developers to place child EditorPart controls within an EditorZone control in the declarative markup of a Web page. 区域模板充当子控件的容器。The zone template acts as a container for the child controls.

备注

属性的 set 访问器 ZoneTemplate 调用 InvalidateEditorParts 方法,这 EditorPart 会强制重新创建在模板中声明的控件的集合。The set accessor for the ZoneTemplate property calls the InvalidateEditorParts method, which forces the collection of EditorPart controls declared in the template to be recreated. 这会导致识别模板内容中的任何更改。This causes any changes in the contents of the template to be recognized.

若要在控件中以声明方式使用区域模板 EditorZone ,请添加一对 <zonetemplate> 标记,并在 EditorPart 标记之间引用控件。To use a zone template declaratively within an EditorZone control, you add a pair of <zonetemplate> tags, and reference EditorPart controls between the tags. 每个控件实例只呈现一个区域模板 EditorZone (因此,没有理由将多个 <zonetemplate> 元素添加到 EditorZone 控件) 。Only one zone template is rendered per instance of an EditorZone control (therefore, there is no reason to add multiple <zonetemplate> elements to an EditorZone control). 此外,控件的区域模板只能 EditorZone 包含从类派生的部件控件 EditorPartAlso, the zone template of an EditorZone control can contain only part controls that derive from the EditorPart class.

适用于

另请参阅