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

I need some C# or powershell script where I need to list down all the web parts that are defined inside a page and not inside a web part zone.

I tried with GetLimitedWebPartManager, but that API, will return only the web parts which are defined inside a web part zone.

But I need an logic, which will give me all the web parts which are not created inside a web part zone.


share|improve this question
WebPartManager wpm = WebPartManager.GetCurrentWebPartManager(this.Page);
int webPartCount = wpm.WebParts.Count;
share|improve this answer
I cannot use WebPartManager as I wont get Page reference, as I am doing a console application. Its not a web application and its a simple console application and I just need to prepare some report – Premchand Peddakotla Jun 26 '13 at 3:56
Use SPLimitedWebPartManager.WebParts . This should give you all the weparts in the page. Source:… – Nadeem Yousuf Jun 26 '13 at 5:13

Use the WebPartManager class. Have a look at the sample code. It uses the GetCurrentWebPartManager method.

share|improve this answer

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.