This documentation is archived and is not being maintained.

WebPartPersonalization.ToggleScope Method

Switches the current page's personalization scope from User to Shared or from Shared to User.

Namespace: System.Web.UI.WebControls.WebParts
Assembly: System.Web (in system.web.dll)

public virtual void ToggleScope ()
public void ToggleScope ()
public function ToggleScope ()
Not applicable.

Exception typeCondition


The current user does not have the user capability to enter Shared scope when attempting to switch from User scope to Shared scope.

- or -

The WebPartPersonalization instance has not completed initialization.

- or -

The Page instance for the associated WebPartManager is a null reference (Nothing in Visual Basic).

- or -

The value of the Request property on the WebPartManager control's associated Page instance is a null reference (Nothing in Visual Basic).


An attempt was made to toggle to a scope that is not defined in the PersonalizationScope enumeration. Technically, this situation should never occur.

This method toggles the currently executing page's personalization scope. Toggling the scope results in a Transfer back to the current executing page.

This method performs no operation if it is called while an export or import of a Web Parts control is occurring.

If a toggle scope request occurs for a page that was submitted via a POST request, then any query string values will be preserved during the transfer; query string parameters are not preserved if the page was submitted via a GET request.

The following code demonstrates using the ToggleScope method. This code is part of a larger code sample found in the WebPartPersonalization class description.

// Allows authorized user to change personalization scope.
protected void Toggle_Scope_Button_Click(object sender, EventArgs e)
    if (_manager.Personalization.CanEnterSharedScope)

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0