Compartilhar via


PublishingService.DisconnectPageLayout Method

Disconnect a PublishingPage object from its PageLayout to make its markup a copy of the page layout's markup.

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

Syntax

'Declaration
<WebMethodAttribute> _
Public Sub DisconnectPageLayout ( _
    pageUrl As String _
)
'Usage
Dim instance As PublishingService
Dim pageUrl As String

instance.DisconnectPageLayout(pageUrl)
[WebMethodAttribute]
public void DisconnectPageLayout(
    string pageUrl
)

Parameters

  • pageUrl
    Type: System.String

    Server-relative URL of the page to be disconnected.

Remarks

When a user navigates to a PublishingPage, the contents of its PageLayout object are used to render the page. Using the contents of the page layout allows page designers to change the markup of a single page layout and affect the display of every page that uses that page layout.

However, there are times when a Web designer needs to create a particular type of page and none of the available page layouts are appropriate. In this scenario, you can disconnect the page from its page layout. The DisconnectPageLayout(System.String) method places a copy of the page layout's markup in the markup of the PublishingPage. The Web designer can then make changes to the markup in the page without affecting any other pages of the same type. 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 DisconnectWidget()
        {
            // 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 someone other than the current user. If you want to use the credentials of the
            // current user then use CredentialCache.DefaultCredentials instead of the NetworkCredential instance used here.
            publishingService.Credentials = new NetworkCredential("<username>", "<password>", "<domain>");

            // Disconnect the page from it's page layout.
            publishingService.DisconnectPageLayout("http://<yourserver>/<yoursite>/Pages/WidgetAnnouncement.aspx");
        }

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

See Also

Reference

PublishingService Class

PublishingService Members

Microsoft.SharePoint.Publishing.WebServices Namespace

ReconnectPageLayout

PublishingService