Blog

How to get the list content types using CSOM in SharePoint 2013

Posted by Vijai Anand Blogs | SharePoint 2013 Jun 28, 2013
In this blog you will see how to get the list content types using CSOM in SharePoint 2013

Namespaces:

using Microsoft.SharePoint.Client;
Assemblies:
Microsoft.SharePoint.Client.dll;
Microsoft.SharePoint.Client.RunTime.dll;
Code Snippet:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;

namespace CSOMSamples
{
class Program
{
static void Main(string[] args)
{
//// String Variable to store the siteURL
string siteURL = "http://c4968397007/";

//// Get the context for the SharePoint Site to access the data
ClientContext clientContext = new ClientContext(siteURL);

//// Get the content type collection for the list "Custom"
ContentTypeCollection contentTypeColl = clientContext.Web.Lists.GetByTitle("Custom").ContentTypes;

clientContext.Load(contentTypeColl);
clientContext.ExecuteQuery();

//// Display the Content Type name
foreach (ContentType ct in contentTypeColl)
{
Console.WriteLine(ct.Name);
}
Console.ReadLine();
}
}
}


COMMENT USING
PREMIUM SPONSORS
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
Employers - Post Free Jobs