Breyta

Deila með


WebPartPersonalization.ToggleScope Method

Definition

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

public:
 virtual void ToggleScope();
public virtual void ToggleScope ();
abstract member ToggleScope : unit -> unit
override this.ToggleScope : unit -> unit
Public Overridable Sub ToggleScope ()

Exceptions

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 null.

-or-

The value of the Request property on the WebPartManager control's associated Page instance is null.

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

Examples

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)
    {
        _manager.Personalization.ToggleScope();
    }
    
}
' Allows authorized user to change personalization scope.
Protected Sub Toggle_Scope_Button_Click(ByVal sender As Object, ByVal e As EventArgs) 
    If _manager.Personalization.CanEnterSharedScope Then
        _manager.Personalization.ToggleScope()
    End If

End Sub 'Toggle_Scope_Button_Click 

Remarks

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.

Applies to

See also