I have custom ArticlePage.aspx page layout.

I have created some pages in Pages library using ArticlePage layout.

Now programmatically. I'm trying to get that pages with their properties.

I did some code but it's not working.

Please suggest some code.


Use below code to find the pages which are using "ArticlePage" layout. SPSiteDataQuery is used for cross site query, so all pages site collection or specific web can be retrieved.

SPWeb web = SPContext.Current.Site.RootWeb;
SPSiteDataQuery query = new SPSiteDataQuery();

//Server template for pages library is 850
query.Lists = "<Lists ServerTemplate='850' Hidden='TRUE' />";  

query.ViewFields = @"<FieldRef Name='URL' Nullable='True' Type='URL' /><FieldRef Name='Title' Nullable='TRUE' Type='Text' />";

query.Webs = "<Webs Scope='Recursive'  />";
query.Query = @"<Where><Eq><FieldRef Name='ContentType'/><Value Type='Text'>ArticlePage</Value></Eq></Where>"
DataTable dt = web.GetSiteData(query);

Hope this might be helpful.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.