views:

334

answers:

1

Is there any way to get all WebPartZones on a given page in MOSS 2007? By iterating over all the Webparts it's possible to get zones with webparts in, but empty Zones won't be included then. Using SPLimitedWebPartManager to get all WebParts on a page.

This needs to be done from a Layouts page.

+2  A: 

Well you can get the SPWebPartManager. Then use the Zones property to iterate over the Zones in the Page.

See http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpartmanager.zones.aspx for more info on using the zones.

I think this may work but you should probably try it.

C#

if(!string.IsNullOrEmpty(this.SPWebPartManager))
{
    WebPartPage l_oPage = (WebPartPage) this.Page;
    SPWebPartManager l_oManager = (SPWebPartManager) l_oPage.Master.FindControl(this.SPWebPartManager);

    if (l_oManager.DisplayMode.Name.Equals(WebPartManager.BrowseDisplayMode.Name))
    {
        foreach (WebZone zone in l_oManager.Zones)
        {
            // Do something with the zone.
        }
    }
}
AboutDev
Thnx, will try asap.
noocyte