SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I find out the zoneID of the zone where my custom webpart is being added? Have tried few things including this one.

AnotherWP.ZoneID = ((WebPart) mgr.WebParts["ControllerID"]).Zone.ID;

But it doesnt seem to work. Thoughts?

share|improve this question
I don't understand. Do you want to get the ID of the zone in which your WebPart has been added? Or do you want to add the webpart to a specific zone? Or do you want to get a collection of all ZoneID's on the current page in order to do a check so you can add your WebPart? – Daniel Ziga Jan 8 '12 at 1:41

Assuming that mg is a SPLimitedWebPartManager:

string zoneId = mgr.GetZoneID(mgr.WebParts["ControllerID"])

Will get the ZoneID of a WebPart that is already inserted into the page.

To insert a web part into a specific Web Part Zone:

mgr.AddWebPart(AnotherWP, targetZoneId, 1);
share|improve this answer
Nope, that returns null as well, as the webpart is not yet added to the zone. – Hna0002 Nov 4 '11 at 17:15
Hahahah yeah, it needs to be in a Zone to get the zone that way! – GavinB Nov 8 '11 at 20:02
in this code: string zoneId = mgr.GetZoneID(mgr.WebParts["ControllerID"]) What is exactly ControllerID? – SharePoint Freak Mar 13 '13 at 12:56

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.