PersonalizationScope 枚举

定义

指示 WebPartManager 对象的个性化设置范围或应用于 Web 部件控件上的属性的个性化设置范围。Indicates the personalization scope for a WebPartManager object or the personalization scope that applies to a property on a Web Parts control.

public enum class PersonalizationScope
public enum PersonalizationScope
type PersonalizationScope = 
Public Enum PersonalizationScope
继承
PersonalizationScope

字段

Shared 1

当引用 WebPartManager 控件上的范围时,Shared 范围是指应用于页面上所有可个性化设置控件的全部用户并可保存在该页面上的个性化设置数据。When referring to the scope on the WebPartManager control, Shared scope means that personalization data applies to all users for all personalizable controls on a page and is also available to be saved on the page.
引用与 Web 部件控件属性关联的作用域时,Shared 作用域表示,属性通常只允许加载或保存与所有用户关联的数据。When referring to the scope associated with a Web Parts control property, Shared scope indicates that the property normally only allows loading or saving of data associated with all users.

User 0

当涉及 WebPartManager 控件上的范围时,User 范围意味着,对于页面上的所有可个性化设置控件,特定于用户的个性化数据以及适用于所有用户的个性化数据都会被加载。When referring to the scope on the WebPartManager control, User scope means that personalization data that is user-specific, as well as personalization data that applies to all users, is loaded for all personalizable controls on a page. 只有特定于用户的个性化设置数据可以保存在页面上。Only personalization data that is user-specific can be saved on the page.
引用与 Web 部件控件属性关联的作用域时,User 作用域表示,属性仅在 Shared 作用域内的页面上运行时,才能加载和存储适用于所有用户的数据。When referring to the scope associated with a Web Parts control property, User scope indicates that the property can only load and store data applicable to all users when running on a page in Shared scope. 但是,如果属性的控件是在 User 作用域内的页面上运行,属性的每用户数据和所有用户数据都会进行加载和合并。However, when the property's control is running on a page in User scope, the property's per-user and all-user data will be loaded and merged. 不过,在这种情况下,每用户数据仅当页面在 User 作用域中运行时才会进行保存。In this case, though, only per-user data will be saved when a page is running in User scope scope.

示例

下面的示例演示如何使用PersonalizationScope枚举:The following example demonstrates using the PersonalizationScope enumeration:

if (_manager.Personalization.Scope == PersonalizationScope.Shared)
{
    TextBox2.Text = "Shared Scope";
}
else
    TextBox2.Text = "User Scope";

注解

个性化设置作用域是 Web 部件个性化的重要概念, 并与其他设置紧密集成, 其中包括在中运行的页面WebPartManager的范围; 与控件上的每个属性关联的作用域; 以及, 其中控件已添加到页面中。Personalization scope is a key concept in Web Parts personalization and is tightly integrated with other settings, including the scope that the page, through the WebPartManager control, is running in; the scope associated with each property on a control; and the way in which the control was added to the page. 有关个性化设置范围的详细信息, 请参阅Web 部件个性化概述For more information on personalization scope, see Web Parts Personalization Overview.

个性化设置范围指的是如何将个性化设置数据应用于不同的用户组。Personalization scope refers to how personalization data is applicable to different sets of users. 某些个性化数据仅适用于特定用户和页面上的控件。Some personalization data is applicable to only a specific user and control on a page. 其他个性化数据适用于查看网站的所有用户。Other personalization data is applicable to all users who view a site. 个性化设置范围用于不同的个性化设置区域, 用于指示应检索和显示的数据集。Personalization scope is used in various areas of personalization to indicate which set of data should be retrieved and displayed.

当页在个性化设置范围Shared中运行时, 这表示只有特定控件的个性化设置数据适用于所有查看控件的用户。When a page is running in Shared personalization scope, this indicates that only the personalization data for a specific control, applicable to all users viewing the control, should be loaded. 根据当前正在执行的用户的权限, 还可以修改此广泛适用的数据, 并将其保存回数据存储中。Depending on the currently executing user's rights, this broadly applicable data can also be modified and saved back to the data store. 当页在个性化设置范围User中运行时, 这表示应基于当前正在执行的用户保存和加载控件的个性化设置数据。When a page is running in User personalization scope, this indicates that a control's personalization data should be saved and loaded based on the currently executing user. 通常, 这意味着可以在控件上加载和保存特定于用户的数据, 并且只能在控件上查看广泛适用的数据 (或共享数据)。Usually, this means user-specific data can be loaded and saved on a control, while broadly applicable data (or shared data) can only be viewed on the control.

管理个性化的高级生命周期的控件在两个个性化设置范围中的一个范围内执行。WebPartManagerA WebPartManager control, which manages the high-level life cycle of personalization, executes in one of the two personalization scopes.

适用于