Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Whenever I try to save og check in mmy Home.aspx pagelayout welcome page I get

Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page.

And this:

Microsoft.SharePoint.Publishing.PublishingPage.GetPublishingPage(SPListItem sourceListItem) +303
   Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageStateControl.RaisePostBackEventForPageRouting(String eventArgument, SPRibbonCommandHandler control, RaisePostBackEventDelegate raisePostBackEventDelegate) +110
   Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageSaveAndStopEditHandler.RaisePostBackEvent(String eventArgument) +134
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981

I have created home.aspx as a new pagelayout as a welcome page. Can anyone see what is wrong?

share|improve this question
add comment

2 Answers 2

It would help to see your code, but you can try this one.
I think this would do the trick.

using (SPSite site = new SPSite("http://myservier"))
{
    using (SPWeb web = site.OpenWeb())
    {
        PublishingSite pSite = new PublishingSite(site);
        SPContentType ctype = pSite.ContentTypes["MyWelcomePage"];
        PageLayoutCollection pageLayouts = pSite.GetPageLayouts(ctype, true);
        PageLayout pageLayout = pageLayouts["/_catalogs/masterpage/PageLayout.aspx"];
        PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(web);
        PublishingPageCollection pPages = pWeb.GetPublishingPages();
        PublishingPage pPage = pPages.Add("home.aspx", pageLayout);
        SPListItem newpage = pPage.ListItem;
        newpage["Title"] = "Page added programmatically";
        newpage.Update();

        newpage.File.CheckIn("CheckIn programmatically");
        newpage.File.Publish("Publish programmatically");
    }

Good luck.

share|improve this answer
    
Please forgive my stupidity - where do I need to place this code? –  Morten Hagh Jan 10 '13 at 14:50
    
Did you create your home.aspx page programmatically? or by using the SharePoint UI? –  Alex Choroshin Jan 10 '13 at 14:56
    
I created it with Sharepoint Designer –  Morten Hagh Jan 10 '13 at 14:58
    
Try to deactivate and reactivate the SharePoint Server Publishing site feature –  Alex Choroshin Jan 10 '13 at 15:02
    
I have tried that - it didn't seem to work ... –  Morten Hagh Jan 10 '13 at 17:02
add comment

From your comments, it seems you created the Page Layout using SharePoint Designer.

Can you try to re-create the Page Layout using SharePoint Design Manager?

Tutorial: http://msdn.microsoft.com/en-us/library/office/jj822368.aspx

share|improve this answer
1  
Water, welcome to SharePoint StackExchange. One of the standards we try to keep is adding at least an over-view of the steps in an answer rather than just offering a link as frequently blog posts and sites move or get deleted. That might not be the case with an MSDN page, but at least and over-view helps improve the quality of our community. –  Robert Kaucher Feb 10 at 3:33
add comment

Your Answer

 
discard

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.