Create A Task List In SharePoint 2013 Using CSOM
In this blog, I would like to share a code snippet for how to create a task list in a SharePoint announcement list, using Client Object Model.
Steps
- Open Visual Studio in your system.
- Select Console Application template and give the name "Enablefolder".
- Add a Microsoft.Cleint Assembly reference file in right side reference tab in Visual Studio.
- Replace Program.cs with the source code given below.
Code snippet
- using System;
- using Microsoft.SharePoint.Client;
-
-
- namespace GowthamArticles
- {
- class CreateList
- {
- static void Main()
- {
-
- ClientContext clientContext = new ClientContext("https://gowtham.sharepoint.com/tutorials");
- ListCreationInformation creationInfo = new ListCreationInformation();
- creationInfo.Title = "New TASKList";
- creationInfo.Description = "THis Task List created PRogrammatically";
- creationInfo.TemplateType = (int)ListTemplateType.Tasks;
- web.Lists.Add(creationInfo);
- context.ExecuteQuery();
-
-
- }
- }
- }