Gets a reference to an object that contains personalization data for a Web page.
Assembly: System.Web (in System.Web.dll)
The WebPartPersonalization object that is associated with a page through the WebPartManager control. Using this property, you can access the various members of the personalization object. For example, you can use the ToggleScope method to switch the page's personalization scope from shared to user scope, or vice versa. You can also find out the current personalization scope of the page, whether personalization is even enabled on the page, which provider is being used for the personalization data, and more.property provides a way to access the
For more information on Web Parts personalization, see Web Parts Personalization Overview.
The following code example demonstrates how to use theproperty programmatically.
The following Web page allows a user to enter edit mode to edit certain aspects of the Calendar control. The Toggle Scope button switches the page to user or shared personalization scope. The Edit Mode and Browse Mode buttons each switch the page into the appropriate display mode. Notice that in the <script> tag section of the file, two of the methods that handle events use the property to access useful members of the underlying object. Specifically, these methods use the ToggleScope method and the Scope property on the object accessed through the property.
For the code example to run, you also must enable a user or users to personalize pages in shared scope. Add an entry to the Web.config file, within the <system.web> section, that looks like the following markup.
<webParts> <personalization> <authorization> <allow users="[Replace the text and brackets with a user name or group.]" roles="admin" verbs="enterSharedScope" /> </authorization> </personalization> </webParts>
After you load the page in a browser, click the Toggle Scope button, and notice that the page now says the scope is shared. Click Edit Mode to change the display mode, click the verbs menu on the visible control, and select Edit from the menu. Notice that the user interface (UI) for both editing controls appears. Now click Browse Mode to return to normal browsing. If the page says it is in shared scope, click Toggle Scope again to ensure the page is in user scope. Next, follow the same steps to edit the control again, but notice that now in the editing UI, the BehaviorEditorPart control does not appear. That is because this control only works when the page is in shared personalization scope.
Available since 2.0