Thursday, December 8, 2016

Creating a new web in SharePoint 2010 using C# and Microsoft.SharePoint.Client;

References

using Microsoft.SharePoint.Client;
using Microsoft.SharePoint;
using SP = Microsoft.SharePoint.Client;

Implementation

            // Starting with ClientContext, the constructor requires a URL to the server running SharePoint.
            ClientContext context2010 = new ClientContext("SharePoint URL");

            WebCreationInformation creation = new WebCreationInformation();
            creation.Url = "New web URL name";
            creation.Title = "New web title";
            Web newWeb = context2010.Web.Webs.Add(creation);

            // Retrieve the new web information.
            context2010.Load(newWeb, w => w.Title);
            context2010.ExecuteQuery();

            MessageBox.Show("Web created");

No comments: