Sunday, 12 April 2015

How to get SharePoint List Content Type Through CSOM - Client Object Model

How to get Content Type of particular list.

Code:

ClientContext clientContext = new ClientContext("Site URL");  
 String strPassword = "Password";  
 var passWord = new SecureString();  
 foreach (var c in strPassword.ToCharArray()) passWord.AppendChar(c);  
 NetworkCredential Cred = new NetworkCredential("Username", passWord, "Domain");  
 clientContext.Credentials = Cred;  
  ContentTypeCollection contentTypeColl = clientContext.Web.Lists.GetByTitle("ContetType Name").ContentTypes;  
       clientContext.Load(contentTypeColl);  
       clientContext.ExecuteQuery();  
       //// Display the Content Type name  
       foreach (ContentType ct in contentTypeColl)  
       {  
         Console.WriteLine(ct.Name);  
       }  
       Console.ReadLine();  

1 comment:

  1. This article clearly explains how to retrieve SharePoint List Content Types using CSOM, making it easier for developers working with Microsoft Technologies . The step-by-step guidance and practical examples make the concept simple to understand for both beginners and advanced users.

    ReplyDelete

Translate