PersonalizationDictionary.Add Method
Assembly: System.Web (in system.web.dll)
public void Add ( String key, PersonalizationEntry value )
public function Add ( key : String, value : PersonalizationEntry )
Not applicable.
Parameters
- key
The unique identifier for a piece of state information.
- value
A piece of state information to be added to the personalization dictionary. This value can be a null reference (Nothing in Visual Basic).
| Exception type | Condition |
|---|---|
| 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 a null reference (Nothing in Visual Basic). - or - value is a null reference (Nothing in Visual Basic). |
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.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.