Export (0) Print
Expand All

WebPartZone.GetInitialWebParts Method

Overrides the abstract base method and gets the initial set of static WebPart controls contained within the zone's template.

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

'Declaration
Protected Friend Overrides Function GetInitialWebParts As WebPartCollection

Return Value

Type: System.Web.UI.WebControls.WebParts.WebPartCollection
A WebPartCollection that contains all the WebPart or other server controls contained in the zone's template.

The GetInitialWebParts method provides an implementation of the abstract base GetInitialWebParts method. The base method provides no implementation, but declares the method so that derived classes can customize how they will get the initial set of controls that belong in a zone, without taking personalization changes into account.

For each server control found in the zone, the CreateWebPart method is called. If a control inherits directly from the WebPart class, it is simply added to the zone's WebParts collection (and to the similar collection of the WebPartManager control). If a control does not inherit directly from WebPart, the Web Parts control set wraps the control with a GenericWebPart object, which enables the control to behave as a WebPart control at run time.

The WebPartZone class implements the base method by returning the set of controls (if any) that are statically declared within a set of <zonetemplate> tags in the markup of a Web Parts page. If a PlaceHolder control is declared in a zone, the child controls of that control are added, rather than the control itself. This implementation allows you to, for example, create a WebPartZone zone in a master page, and then declare individual WebPart or server controls in a content page. If you declare Literal controls in a WebPartZone zone, they are ignored.

NoteNote

The initial collection of controls returned by the GetInitialWebParts method might be different from the actual run-time collection of controls in a zone, after personalization has taken place. For example, suppose you have a Web page with two WebPartZone controls, and the first one contains user control named User1 that is statically declared within the <zonetemplate> tags. If a user loads the page and drags User1 into the second zone, then User1 is still part of the collection that is returned by calling the GetInitialWebParts method for the first zone, because it is declared in that zone. But at run time, when the WebPartManager control loads the personalization data, User1 actually appears in the second zone where the user dragged it.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft