WebPartZone.ZoneTemplate Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a reference to an ITemplate instance that contains the controls declared in the markup of a Web page.
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.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.TemplateInstance(System.Web.UI.TemplateInstance.Single)>]
member this.ZoneTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property ZoneTemplate As ITemplate
An ITemplate that contains the WebPart controls in a zone.
- Attributes
Registration of the WebPart controls in the zone is already complete.
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>
<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>
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.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: