We can create a new SharePoint site as a subsite of the current website using the below given C# code .
We will use the WebCreationInformation class to create a new website. You will also need to add using statements for System.Collections.Generic and System.Text.
The class WebCreationInformation inherits from class ClientValueObject of Namespace Microsoft.SharePoint.Client
We will use the WebCreationInformation class to create a new website. You will also need to add using statements for System.Collections.Generic and System.Text.
// Starting with ClientContext, the constructor requires a URL to the // server running SharePoint. ClientContext context = new ClientContext("http://SiteUrl"); WebCreationInformation creation = new WebCreationInformation(); creation.Url = "web1"; creation.Title = "Hello web1"; Web newWeb = context.Web.Webs.Add(creation); // Retrieve the new web information. context.Load(newWeb, w => w.Title); context.ExecuteQuery(); label1.Text = newWeb.Title;
The class WebCreationInformation inherits from class ClientValueObject of Namespace Microsoft.SharePoint.Client
No comments:
Post a Comment