PublishingService.ReconnectPageLayout Method

Use this method to reconnect a PublishingPage object to its PageLayout object and replace its custom markup with default PublishingPage markup.

Namespace:  Microsoft.SharePoint.Publishing.WebServices
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
<WebMethodAttribute> _
Public Function ReconnectPageLayout ( _
    pageUrl As String _
) As String
'Usage
Dim instance As PublishingService
Dim pageUrl As String
Dim returnValue As String

returnValue = instance.ReconnectPageLayout(pageUrl)
[WebMethodAttribute]
public string ReconnectPageLayout(
    string pageUrl
)

Parameters

  • pageUrl
    Type: System.String

    Server-relative URL of the PublishingPage to be reconnected.

Return Value

Type: System.String
A String of the form ReturnCode,URL.
A ReturnCode of 1 means that the PublishingPage is reconnected to the same PageLayout object specified in URL from which it was originally disconnected.
A ReturnCode of 2 means that the PublishingPage was not reconnected to the same PageLayout object specified in URL from which it was originally disconnected. Instead, it was reconnected to one of the available PageLayout objects for the content type of this PublishingPage.

Remarks

This method first attempts to reconnect the page to the same page layout that was previously used. However, if that page layout no longer exists because it was renamed or deleted, the method uses the content type of the page to find the first PageLayout object it can find for that content type. The PublishingPage object then reconnects to that PageLayout object.

You must have the AddAndCustomizePages() permission to call this method.

Examples

using System;
using System.Net;
using PublishingServiceUtility.PublishingWebService;

namespace PublishingServiceUtility
{
    public class Program
    {

        internal static void ReconnectWidget()
        {
            // Add a Web reference to the Web service located at "http://<yourserver>/<yoursite>/_vti_bin/PublishingService.asmx"
            // using the name PublishingWebService and Visual Studio to generate the PublishingService proxy object.

            // Create and initialize the PublishingService proxy object.
            PublishingService publishingService = new PublishingService();
            publishingService.Url = "http://<yourserver>/<yoursite>/_vti_bin/PublishingService.asmx";
            publishingService.AllowAutoRedirect = false;

            // This sample uses the credentials of the current user. If you want to use the credentials of a different user
            // then create a new NetworkCredential instance and use that instead of the DefaultCredentials used here.
            publishingService.Credentials = CredentialCache.DefaultCredentials;

            // Reconnect the page to its page layout.
            publishingService.ReconnectPageLayout("http://<yourserver>/<yoursite>/Pages/WidgetAnnouncement.aspx");
        }

        public static void Main(string[] arguments)
        {
            ReconnectWidget();
        }

    } // class Program

See Also

Reference

PublishingService Class

PublishingService Members

Microsoft.SharePoint.Publishing.WebServices Namespace

DisconnectPageLayout

PublishingService