Create Site Using Client Object Model in .net Model
In C# ,
In Order to work with .net managed Code ,We need to refer Microsoft.SharePoint.Client.dll from ISAPI folder in 15 hive .
Once this is done,we can write a Windows or Console Application for creating a Sample Site Creation .
In C# ,
In Order to work with .net managed Code ,We need to refer Microsoft.SharePoint.Client.dll from ISAPI folder in 15 hive .
Once this is done,we can write a Windows or Console Application for creating a Sample Site Creation .
string siteDescription="New Site created using .net Managed Client";
siteTitle="TestSite";
siteUrl="http://servername/"
public void CreateSite(string siteDescription, string siteTitle, string siteUrl) { rootWeb = rootWeb.Webs.Add(new WebCreationInformation { Description = siteDescription, Title = siteTitle, Url = siteUrl, UseSamePermissionsAsParentSite = false }); clientContext.ExecuteQuery(); }
Nice Article
ReplyDeletePlease Let us know how to confirm the site is created or not
Hi Rambabu ,
ReplyDeleteThanks for visiting the Blog ,
I have created a WindowsForm Application Which takes Site Title ,URL ,Desc as Input Paramters and Creates Site ,. On button Click the below Code runs and creates site inside the specified site.After this Check Site Contents a new site created in Subsites section
private void btnCreateSite_Click(object sender, EventArgs e)
{
try
{
COM.ClientContext contx = new COM.ClientContext(new Uri("Server URL"));
contx.Credentials = new System.Net.NetworkCredential("Username", "Password", "domain");
string siteDescription = txtDesc.Text;
string siteTitle = txtTitle.Text.Trim();
string siteUrl = txtURL.Text;
COM.Web Web = contx.Web.Webs.Add(new COM.WebCreationInformation
{
Description = siteDescription,
Title = siteTitle,
Url = siteUrl,
UseSamePermissionsAsParentSite = true
});
lblSiteDec.Visible = true;
try
{
contx.ExecuteQuery();
lblSiteDec.Text = Web.Title.ToString();
}
catch (Exception ex)
{
lblSiteDec.Text="SiteName Already in Use";
}
}
catch(Exception EX)
{
throw EX;
}
}