SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know the name of the layout page. Do I still have to go through this process to get the layout page?

foreach (PageLayout pl in pageLayouts)
if (pl.Name.Equals("MyLayout.aspx", StringComparison.InvariantCultureIgnoreCase))
    currPageLayout = pl;
share|improve this question
I guess if I know the content type id then it can be.… PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts(contentType.Id); – Monica Contera May 12 '11 at 13:58
what is your variable pageLayouts? – Abe Miessler May 12 '11 at 15:22

Since a PageLayout is just an SPFile in an SPList (Master Page Gallery), you can get a reference to the SPFile and use the PageLayout constructor to get your PageLayout by passing in SPFile.Item

Something like this

new PageLayout(site.RootWeb.Files["webrelativeurltoyourpagelayout.aspx"].Item);
share|improve this answer
that did not work. hmm. any other suggesion(s)? – Monica Contera May 18 '11 at 17:16
Did you manage to get a valid reference to the SPFile? What value did you use for webrelativeurltoyourpagelayout.aspx? – Jaap Vossers May 24 '11 at 13:14
this worked for me: new PageLayout(site.RootWeb.GetFile("_catalogs/masterpage/newLayout.aspx").Item); – Chloraphil Feb 7 '13 at 0:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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