ScriptManager::RegisterDataItem Method (Control, String, Boolean)
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
public: void RegisterDataItem( Control^ control, String^ dataItem, bool isJsonSerialized )
If the dataItem parameter that you register for control is not serialized as JSON, set the isJsonSerialized parameter to false. This avoids the need to use the eval function for each string that is sent to the client. For more information about the JSON format, see the Introducing JSON Web site.
The data items that are registered by using the RegisterDataItem method can be accessed in client script during the pageLoading, pageLoaded, and endRequest events of the PageRequestManager object. When you handle these events, the custom data is passed in an event argument object. For example, if you provide a handler for the pageLoading event, the custom data is passed in the PageLoadingEventArgs class, which exposes a dataItems property.
The following example shows how to send data to two Label controls on a page during an asynchronous postback. The Label controls are not inside an UpdatePanel control. This example shows the overload that does not take the isJsonSerialized parameter. Otherwise, the procedure for retrieving the dataItems property of the PageLoadingEventArgs object is the same as if you did not use that overload.
The data that is sent in this example is for illustration only. In a real-world application, you would use the RegisterDataItem method to send custom data from the server. For example, you could use the data item to send information about whether to hide or show client elements that are not inside an UpdatePanel control.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.