Monday 8 June 2015

Create and update a SharePoint list using Client Side object Model

This example creates a SharePoint list and updates it using the ListCreationInformation class.


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

// The SharePoint web at the URL.
Web web = context.Web; 

ListCreationInformation creationInfo = new ListCreationInformation(); 
creationInfo.Title = "My List"; 
creationInfo.TemplateType = (int)ListTemplateType.Announcements; 
List list = web.Lists.Add(creationInfo); 
list.Description = "New Description"; 

list.Update(); 
context.ExecuteQuery(); 
Like WebCreationInformation it also inherits from class ClientValueObject of Namespace Microsoft.SharePoint.Client

No comments: