Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am having trouble finding documentation on the web part zone's attributes. Can someone point me in the right direction? I have done this, and it seemed to work, but it was just a guess:

wpm.AddWebPart(report, "Zone 1", 1);

I am looking for the zone and zoneIndex...

public WebPart AddWebPart(
    WebPart webPart,
    WebPartZoneBase zone,
    int zoneIndex
)

Thanks.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

First of all zoneIndex is where in the zone the Web Part should go. 0-first place, 1-second place etc. For horizontal zones its from left to right and vertical top to bottom.

By looking at the method declaration you have written in your Q I'm seeing that you are using the SPWebPartManager (or just WebPartManager) to add the Web Parts. Do not do this, use the SPLimitedWebPartManager where you instead use the id (string) of the zone like this:

spLimitedWebPartManager.AddWebPart(webPart, "Top", 0);

That would add the Web Part (webPart) to the zone with ID=Top and at the first position.

To get the ID's of the zone you can either look at the page and look for the WebPartZone controls, iterate over the control-tree in the page and find all WebPartZone controls or use the (SP)WebPartManager Zones property which gives you a collection of available zones.

share|improve this answer

What information do you need specifically?

There is much on the WebPartZone alone on MSDN:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpartzone.aspx

share|improve this answer
    
Well, for example... Does "Zone 1", 1 = The top left web part zone? I just need the correlation of "thisZone" = zoneID Does each zone have a specific zoneid? –  Anonymous Aug 4 '10 at 17:48

The zone ID is listed in the ASP page and may vary by MasterPage. The easiest way to get a quick view is to load an aspx page into SharePoint designer and look at the web part zones in code view. Look for the WebPartZone element and find the ID attribute.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.