WebPartPersonalization Class

 

Implements low-level personalization operations.

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

System::Object
  System.Web.UI.WebControls.WebParts::WebPartPersonalization

public ref class WebPartPersonalization 

NameDescription
System_CAPS_pubmethodWebPartPersonalization(WebPartManager^)

Initializes a new instance of the WebPartPersonalization class.

NameDescription
System_CAPS_pubpropertyCanEnterSharedScope

Returns a value indicating whether the user is authorized to enter Shared scope.

System_CAPS_pubpropertyEnabled

Returns a value indicating whether personalization is requested to be enabled for the associated WebPartManager control.

System_CAPS_pubpropertyHasPersonalizationState

Returns a value indicating whether the current page and personalization scope have associated personalization data.

System_CAPS_pubpropertyInitialScope

Gets or sets the default personalization scope.

System_CAPS_pubpropertyIsEnabled

Gets a value that indicates whether personalization is enabled and has successfully loaded personalization data for this instance of the WebPartPersonalization class.

System_CAPS_protpropertyIsInitialized

Gets a value that indicates whether personalization is enabled and has successfully loaded personalization data for this instance of the WebPartPersonalization class.

System_CAPS_pubpropertyIsModifiable

Gets a value that indicates whether the current user is authorized to modify state information.

System_CAPS_pubpropertyProviderName

Gets or sets the provider name for personalization.

System_CAPS_pubpropertyScope

Gets the current personalization scope for the parent WebPartManager control.

System_CAPS_protpropertyShouldResetPersonalizationState

Gets or sets a value that indicates whether the personalization data of the current page has been reset (for example, a request was made to delete the personalization data from the underlying data store).

System_CAPS_protpropertyUserCapabilities

Gets the set of user capabilities from WebPartUserCapability granted to the current user.

System_CAPS_protpropertyWebPartManager

Gets an instance of the current parent WebPartManager control associated with this WebPartPersonalization instance.

NameDescription
System_CAPS_protmethodApplyPersonalizationState()

Applies personalization data to the parent WebPartManager control.

System_CAPS_protmethodApplyPersonalizationState(WebPart^)

Applies personalization data to the specified WebPart control when requested to do so by the parent WebPartManager control.

System_CAPS_protmethodChangeScope(PersonalizationScope)

Changes the current page's PersonalizationScope instance to the scope specified.

System_CAPS_protmethodCopyPersonalizationState(WebPart^, WebPart^)

Extracts the personalization state from one Web Parts control and applies it to a second Web Parts control.

System_CAPS_pubmethodEnsureEnabled(Boolean)

Ensures that the WebPartPersonalization instance has completed initialization or that the current user has rights to modify personalization state.

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodExtractPersonalizationState()

Extracts personalization data from the parent WebPartManager control.

System_CAPS_protmethodExtractPersonalizationState(WebPart^)

Extracts personalization data from a Web Parts control when requested to do so by the parent WebPartManager control.

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_protmethodGetAuthorizationFilter(String^)

Retrieves the authorization filter, if any, associated with the specified Web Parts control.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodLoad()

Initializes personalization.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodResetPersonalizationState()

Resets personalization data for the current page, scope, and user in the underlying data store.

System_CAPS_protmethodSave()

Saves personalization data for the current page, scope, and user to the underlying data store.

System_CAPS_protmethodSetDirty()

Marks the parent WebPartManager control as having personalization data that has changed (is "dirty").

System_CAPS_protmethodSetDirty(WebPart^)

Marks the specified Web Parts control as having personalization data that has changed (is "dirty").

System_CAPS_pubmethodToggleScope()

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

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticEnterSharedScopeUserCapability

Represents the WebPartUserCapability instance of a user's authorization to enter Shared scope.

System_CAPS_pubfieldSystem_CAPS_staticModifyStateUserCapability

Represents the WebPartUserCapability instance of a user's authorization to modify personalization state.

This class implements the logic required to carry out lower-level personalization operations. Although the WebPartManager class manages the high-level life cycle of personalization, it is the WebPartPersonalization class that is responsible for actually implementing the physical steps necessary to carry out specific personalization actions. The WebPartPersonalization class in turn relies on an implementation of PersonalizationProvider to communicate with the underlying data store for personalization information.

If you use the default implementation of the WebPartManager, it creates an instance of the WebPartPersonalization class that you can use by referencing the Personalization property. For example, to access the InitialScope property, you would specify WebPartManager.Personalization.InitialScope.

Notes to Inheritors:

The WebPartPersonalization class works closely with a WebPartManager control and the rest of the personalization infrastructure. The default implementation of personalization is a very robust subsystem that should meet your personalization needs. In most cases, if you want to customize personalization, you can create a data provider for use as a personalization provider by creating a class that inherits from PersonalizationProvider.

If you want to create a personalization subsystem significantly different from that provided by the WebPartPersonalization and the WebPartManager classes, you should create a custom WebPartPersonalization implementation by deriving from WebPartPersonalization and add your own custom logic. Then create a custom WebPartManager implementation by deriving from WebPartManager, add your own custom logic, and override the CreatePersonalization method to return your custom WebPartPersonalization implementation. Because a WebPartManager control makes requests to the personalization infrastructure by way of a WebPartPersonalization instance, the WebPartManager control does not directly interact with or hold references to PersonalizationProvider implementations.

The following code example shows how the WebPartPersonalization class is used, as well as providing an example of how personalization scope affects the results of personalized properties. This example has five files:

  • An .aspx page that declaratively creates two Web Part zones, each with a control.

  • A user control called Color.ascx that allows a user to change a personalized property that applies a text box background color based on the user's authorization rights to modify state information and to enter shared scope.

  • A user control called Persmode.ascx that indicates what the current page scope is and what rights the current user has to enter shared scope or to modify data; it also provides two buttons; one to change scope and one to reset current user personalization information.

  • A login control that is used to authorize users.

  • A Web.config file with a section that provides an example of authorizing a user to modify personalization state and to enter shared scope.

The following code creates an aspx page with a WebPartManager and two Web Part zones and displays the Color.ascx and Persmode.ascx controls. The page loads a login page that is used to get the current user information. Use the ASP.NET Web Site Administration Tool in Microsoft Visual Studio 2005 to create users to access the page. See the Web.config file for an example of a user granted authorization in the configuration file to change scope and modify state information.

No code example is currently available or this language may not be supported.

The following example code creates a login page. After a successful login, it redirects to the main aspx page.

System_CAPS_security Security Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

No code example is currently available or this language may not be supported.

The following example code is a portion of the Web.config file for this application. This section shows how to set authorization for a user, in this case "user2", to enter shared personalization scope and to modify personalization state information. It also shows an example of a role, in this case "admin", that can be used to allow users in the "admin" role to enter shared personalization scope and to modify personalization state information.

The following example code creates a user control, called Color.ascx, that allows the user to change a personalized property, in this case the background color of two text boxes, based on the current personalization scope and the authorization rights of the user.

System_CAPS_security Security Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

No code example is currently available or this language may not be supported.

The following example code creates a user control, called Persmode.ascx, that shows the current personalization scope and the user rights to modify state and to enter shared scope. It also has a reset button for resetting the current personalization state.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: