1

I want to get all masterpages in client object model. For classic lists and libraries, I use

context.Web.Lists.GetByTitle(listname)

How do I do that to get the masterpage list (_catalogs/masterpage) ?

Thanks in advance.

3 Answers 3

3

The Title of the list is "Master Page Gallery". Remember that, that lists also contains things other than the master pages. For example, Page Layouts, images for the page layouts etc.

The link below shows how to filter master pages:

https://stackoverflow.com/questions/1716074/retrieve-all-master-pages-for-a-sharepoint-site

1
  • Thanks, it works. For other reasons, I ended up doing context.Web.GetFolderByServerRelativeUrl("_catalogs/masterpage"). Mainly because I'd rather have a Folder object. Commented Jan 26, 2012 at 14:41
3

Another good way of getting a SharePoint Catalog is:

var value = SP.Site.getCatalog(116);

As described here (TypeCatalog enumeration)

1

In the root web context, try:

context.Web.Lists.GetByTitle("Master Page Gallery")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.