Export (0) Print
Expand All

WebPartZone.ZoneTemplate Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a reference to an ITemplate instance that contains the controls declared in the markup of a Web page.

Namespace: System.Web.UI.WebControls.WebParts
Assembly: System.Web (in system.web.dll)

[TemplateInstanceAttribute(TemplateInstance.Single)] 
public virtual ITemplate ZoneTemplate { get; set; }
/** @property */
public ITemplate get_ZoneTemplate ()

/** @property */
public void set_ZoneTemplate (ITemplate value)

public function get ZoneTemplate () : ITemplate

public function set ZoneTemplate (value : ITemplate)

Property Value

An ITemplate that contains the WebPart controls in a zone.

Exception typeCondition

InvalidOperationException

Registration of the WebPart controls in the zone is already complete.

The ZoneTemplate property refers to an ITemplate instance within a WebPartZone control. The template contains static server controls that you can declare within a WebPartZone control, including WebPart controls, user controls, custom controls, and ASP.NET controls.

When you add static WebPart or other server controls to a WebPartZone in the declarative markup of a Web page, you must place the tags for the controls within a pair of <zonetemplate> tags. If you do not declare the controls within <zonetemplate> tags, an exception is thrown.

The following code example demonstrates the use of the ZoneTemplate property in the declarative markup of a Web Parts page. The full code for the example, including a custom class and an .aspx page to host the control, is found in the Example section of the WebPartZone class overview topic.

Notice that, in the markup for the WebPartZone control, there is a <zonetemplate> element that contains a reference to the Calendar control. If you wanted to add additional WebPart controls or other server controls to the zone, you could also add them within the <zonetemplate> tags.

<cc1:MyWebPartZone ID="MyWebPartZone1" runat="server">
  <VerbStyle Font-Italic="true" />
  <PartChromeStyle BackColor="lightblue" />
  <PartStyle BackColor="gray" />
  <PartTitleStyle Font-Bold="true" />
  <ZoneTemplate>
    <asp:Calendar ID="Calendar1" runat="server" 
      Title="My Calendar" />
  </ZoneTemplate>
</cc1:MyWebPartZone>

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft