Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

The following code iterates through the pages in our wiki then tries to add a new one. It adds fine but the PageLayout is changed to null after the page is added. Is there any way to set the PageLayout on a new page using web service calls? I'm trying to avoid using the Microsoft.Sharepoint library.

        ServiceReference1.HomeDataContext home = new HomeDataContext(new Uri("http://utah:82/_vti_bin/ListData.svc"));            
        home.Credentials = System.Net.CredentialCache.DefaultCredentials;

        foreach (var Page in home.Pages)
        {
            this.TxtActivity.AppendText("Page: " + Page.Name + Environment.NewLine);
            int acnt = 0;
        }

        PagesItem page = new PagesItem();
        page.ApprovalStatus = "0";
        page.Name = "TestCodePage1.aspx";
        page.ContentType = "Enterprise Wiki Page";            
        page.ContentTypeID = "0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004C1F8B46085B4D22B1CDC3DE08CFFB9C0004D854AA15019B4CBC2BCC51663D50F6";
        page.Path = "/Pages";            
        page.Title = "Testy Code Pagey1";
        page.PageLayout = @"http://utah:82/_catalogs/masterpage/EnterpriseWiki.aspx, Basic Page";

        home.AddToPages(page);

        home.SetSaveStream(page, new MemoryStream(Encoding.UTF8.GetBytes("Test code testy. ")), false, page.ContentType, page.Path + @"\" + page.Name);
        home.SaveChanges();            
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.