Sunday, 13 July 2014

Create Sharepoint List Using Cleint Object model

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
    class CreateList
    {
        static void Main()
        {           
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web oWebsite = clientContext.Web;

            ListCreationInformation listCreationInfo = new ListCreationInformation();
            listCreationInfo.Title = "My Announcements List";
            listCreationInfo.TemplateType = (int)ListTemplateType.Announcements;

            List oList = oWebsite.Lists.Add(listCreationInfo);

            clientContext.ExecuteQuery();
        }
    }
}

No comments:

Post a Comment