Редагувати

Поділитися через


EditorZone.ZoneTemplate Property

Definition

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

Property Value

An ITemplate zone template that acts as a container for child controls in the zone.

Attributes

Examples

The following code example demonstrates declarative use of the ZoneTemplate property. The full code for the example is found in the Example section of the EditorZone class overview.

The 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. 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. With the editing UI visible, you can see the several EditorPart controls that are declared within the <zonetemplate> element.

Remarks

The ZoneTemplate property is the key difference between the EditorZone class and the base EditorZoneBase class. 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.

Note

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.

To use a zone template declaratively within an EditorZone control, you add a pair of <zonetemplate> tags, and reference EditorPart controls between the tags. 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). Also, the zone template of an EditorZone control can contain only part controls that derive from the EditorPart class.

Applies to

See also