Thursday, December 8, 2016

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


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


            // 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);

            MessageBox.Show("Web created");

No comments: