Szerkesztés

Megosztás a következőn keresztül:


PersonalizationDictionary.Add(String, PersonalizationEntry) Method

Definition

Adds personalization entries to the personalization dictionary.

public:
 virtual void Add(System::String ^ key, System::Web::UI::WebControls::WebParts::PersonalizationEntry ^ value);
public virtual void Add (string key, System.Web.UI.WebControls.WebParts.PersonalizationEntry value);
abstract member Add : string * System.Web.UI.WebControls.WebParts.PersonalizationEntry -> unit
override this.Add : string * System.Web.UI.WebControls.WebParts.PersonalizationEntry -> unit
Public Overridable Sub Add (key As String, value As PersonalizationEntry)

Parameters

key
String

The unique identifier for a piece of state information.

value
PersonalizationEntry

A piece of state information to be added to the personalization dictionary. This value can be null.

Exceptions

key is a duplicate of a key already in the dictionary.

-or-

key is either an empty string ("") or trimming key results in an empty string.

-or-

value is not a PersonalizationEntry.

key is null.

-or-

value is null.

Remarks

You can call this method, place various pieces of custom state information into the state object, and specify the scope associated with the state value. When a WebPartManager control is in Shared scope, you can add name and state information that is associated with either Shared scope or User scope. In User scope, you can add name and state information associated only with User scope.

It is a good practice, however, to add all properties to the dictionary using Save including properties with User or Shared scope, regardless of the scope of the page.

The .NET Framework only saves the properties with Shared scope when appropriate. In other words, shared properties are not saved when a WebPart control that was initially added in Shared scope is later saved while the page is in User scope. In an opposite scenario, if a WebPart control was added to the page in User scope, and the control is later saved while the page is in Shared scope, custom shared property values are saved (along with custom user-scoped properties). For details on personalization data and how shared and user-scoped properties are affected by the personalization scope of the page, see the Web Parts Personalization Overview topic.

As with any collection, this method increments the collection count by one and any enumerators currently active on the collection should be invalidated.

Applies to

See also