In C# code get Article pages Title & Description from page Library...

For this I used below code:-

ClientContext clientContext = new ClientContext("siteUrl");
clientContext.Credentials = cred;
var contentTypeId ="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D";
var oList = clientContext.Web.Lists.GetByTitle("Pages");
CamlQuery camlQuery = new CamlQuery();               
camlQuery.ViewXml = @"<View><Query><Where><Eq><FieldRef Name='ContentTypeId'/><Value Type='ContentTypeId'>"+contentTypeId+"</Value></Eq></Where></Query></View>";
ListItemCollection collListItem = oList.GetItems(camlQuery);
foreach (ListItem oListItem in collListItem)
   Event item = new Event();
   item.Title = oListItem["Title"].ToString();
  • what's the issue here ? for description, you can use Convert.ToString(oListItem["Comments"]); which is the OOTB field or if you have custom field you can use that – Gautam Sheth May 24 '17 at 12:41
  • In collListItem count get 0.but In Pages Library I created 5 Article pages. – Sarika Koli May 24 '17 at 12:48
  • Looks like issue with content type id value. Try this caml query: camlQuery.ViewXml = @"<View><Query><Where><Contains><FieldRef Name='ContentTypeId'/><Value Type='ContentTypeId'>"+contentTypeId+"</Value></Contains></Where></Query></View>"; or change the content type id to 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00E4823458F34FF84EBBF6A21D1ABA5C6F and check – Gautam Sheth May 24 '17 at 12:52
  • Not worked above query – Sarika Koli May 24 '17 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.