1

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

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:

http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/

http://social.msdn.microsoft.com/Forums/sharepoint/en-US/3aa29b38-c7ac-447c-acb5-efcdbc4f4ab3/its-possible-add-custom-webparts-programmatically-in-sharepoint-online?forum=sharepointdevelopmentprevious

  • 4
    Besides that, sandboxed solutions containing code are not supported in Office 365 – Robert Lindgren Sep 18 '14 at 5:40
2

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, privacy policy and cookie policy

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