0

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.

-Premchand

1
WebPartManager wpm = WebPartManager.GetCurrentWebPartManager(this.Page);
int webPartCount = wpm.WebParts.Count;
  • 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: msdn.microsoft.com/en-us/library/… – Nadeem Yousuf Jun 26 '13 at 5:13
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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