# Changing PublishingPage.Layout doesn't change the content type?

I'm trying to update the Layout of the default.aspx page in my SharePoint publishing site and although the Layout does get updated, the ContentType of the page does not. Anyone have any ideas?

Based on the example below, the assert is getting thrown all the time since the content types don't match.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.publishingpage.contenttype.aspx

-

Sounds right to me, any given content type can use many page layouts some page layouts will even work for content types that decendants of the intended content type.

You should change the content type first then change the page layout.

-Gavin

-
For a publishing page, how do you change the content type? I thought changing the layout is supposed to automatically change the content type too. But it doesn't seem to be doing this on my SharePoint site. Oh, and just incase I wasn't clear, I'm doing this via the object model. –  TehOne Mar 6 '12 at 6:31
You can change the content type of the page via the ContentTypeId field. Once that is set you can then change the PageLayout to one associated with the new content type. –  GavinB May 14 '12 at 3:40
Just thought I'd come back an post an update on this. Just changing the page layout wasn't enough for me, I had to also set the ContentTypeId as @GavinB suggested. Here is a code snippet: page.Layout = newPageLayout; page.ListItem[SPBuiltInFieldId.ContentTypeId] = newPageLayout.AssociatedContentType.Id; page.Update(); –  TehOne Aug 18 '12 at 2:25

You may want to change the page layout to change the look, feel, and content of the page. In that case, you can have the different layout associated to same content type.

The ContentType property value is initialized when you create a PublishingPage; this value is based on the AssociatedContentType and cannot be modified.

Another option is to recreate the page using new layout\contentType

-