I want to add a webpart to a page in SharePoint online programmatically. I know the page name, but don't the webpartzone id since it is SharePoint online. Is it still possible to add my webpart to the page programmatically? If yes how?

2 Answers 2


One of the challenges when working with Sandboxed Solutions is how to provision Web Parts instances to pages. If you have done this before in a Farm Solution you know, that in order to add a Web Part to a page programmatically in SharePoint you have to retrieve the instance of the SPLimitedWebPartManager class and use it to add the instance of a Web Part to a page. Unfortunately, as the SDK mentions, the SPLimitedWebPartManager class is not available in Sandboxed Solutions which means that you cannot programmatically add a Web Part to a page from within a Sandboxed Solution.

For more detials check:



  • 4
    Besides that, sandboxed solutions containing code are not supported in Office 365 Sep 18, 2014 at 5:40

What I would do is take a look at the OfficeDev Patterns and Practices project on Github. There are plenty of examples for writing CSOM for SharePoint Online.

All examples are using the new App Model with plenty of helper classes available to do what you need.

The projects in particular that you will want are the Provisioning.Pages and Provisioning.Publishing ones.

Hope these help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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