Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Skip Navigation Links.
ScriptManager Class
ScriptManager Constructor
AllowCustomErrorsRedirect Property
AsyncPostBackError Event
AsyncPostBackErrorMessage Property
AsyncPostBackSourceElementID Property
AsyncPostBackTimeout Property
AuthenticationService Property
EnablePageMethods Property
EnablePartialRendering Property
EnableScriptGlobalization Property
EnableScriptLocalization Property
GetCurrent Method (page)
IsDebuggingEnabled Property
IsInAsyncPostBack Property
LoadPostData Method (postDataKey, postCollection)
LoadScriptsBeforeUI Property
OnAsyncPostBackError Method (e)
OnInit Method (e)
OnPreRender Method (e)
OnResolveScriptReference Method (e)
ProfileService Property
RaisePostDataChangedEvent Method
RegisterArrayDeclaration Method
RegisterArrayDeclaration Method (control, arrayName, arrayValue)
RegisterArrayDeclaration Method (page, arrayName, arrayValue)
RegisterAsyncPostBackControl Method (control)
RegisterClientScriptBlock Method
RegisterClientScriptBlock Method (control, type, key, script, addScriptTags)
RegisterClientScriptBlock Method (page, type, key, script, addScriptTags)
RegisterClientScriptInclude Method
RegisterClientScriptInclude Method (control, type, key, url)
RegisterClientScriptInclude Method (page, type, key, url)
RegisterClientScriptResource Method
RegisterClientScriptResource Method (control, type, resourceName)
RegisterClientScriptResource Method (page, type, resourceName)
RegisterDataItem Method
RegisterDataItem Method (control, dataItem)
RegisterDataItem Method (control, dataItem, isJsonSerialized)
RegisterDispose Method (control, disposeScript)
RegisterExpandoAttribute Method (control, controlId, attributeName, attributeValue, encode)
RegisterExtenderControl Method (extenderControl, targetControl)
RegisterHiddenField Method
RegisterHiddenField Method (control, hiddenFieldName, hiddenFieldInitialValue)
RegisterHiddenField Method (page, hiddenFieldName, hiddenFieldInitialValue)
RegisterOnSubmitStatement Method
RegisterOnSubmitStatement Method (control, type, key, script)
RegisterOnSubmitStatement Method (page, type, key, script)
RegisterPostBackControl Method (control)
RegisterScriptControl Method (scriptControl)
RegisterScriptDescriptors Method
RegisterScriptDescriptors Method (extenderControl)
RegisterScriptDescriptors Method (scriptControl)
RegisterStartupScript Method
RegisterStartupScript Method (control, type, key, script, addScriptTags)
RegisterStartupScript Method (page, type, key, script, addScriptTags)
Render Method (writer)
ResolveScriptReference Event
ScriptMode Property
ScriptPath Property
Scripts Property
Services Property
SetFocus Method
SetFocus Method (clientID)
SetFocus Method (control)
SupportsPartialRendering Property
Visible Property

RegisterDataItem Method (control, dataItem, isJsonSerialized)

Sends custom data that is represented by a string to a control during partial-page rendering, and indicates whether the string is in JavaScript Object Notation (JSON) format.

Syntax

CSharp

public void RegisterDataItem (
	Control control,
	string dataItem,
	bool isJsonSerialized
)

VisualBasic

Public Sub RegisterDataItem ( _
	control As Control, _
	dataItem As String, _
	isJsonSerialized As Boolean _
)

ManagedCPlusPlus

public:
void RegisterDataItem (
	Control^ control, 
	String^ dataItem, 
	bool isJsonSerialized
)

JSharp

public void RegisterDataItem (
	Control control,
	String dataItem,
	boolean isJsonSerialized
)

Parameters

control (Control)

The page control that is receiving the data.

dataItem (String)

The data that is sent to the control.

isJsonSerialized (Boolean)

A Boolean value that indicates whether dataItem is serialized as JSON.

Remarks

Use the RegisterDataItem method to send data from the server to the client during asynchronous postbacks, regardless of whether the control receiving the data is inside an UpdatePanel control.

If the dataItem parameter that you have registered for the control parameter is not serialized as JSON, set the isJsonSerialized parameter to false. This avoids the need to use the eval Method (JScript) function for each string that is sent to the client. For more information about the JSON format, see the Introducing JSON Web site.

The RegisterDataItem method can be called only during an asynchronous postback. To determine whether a postback is asynchronous, use the IsInAsyncPostBack property.

The data items that are registered with the RegisterDataItem method can be accessed in client script in the pageLoading, pageLoaded, and endRequest events of the PageRequestManager class. When you provide a handler for these events, custom data is passed with an event argument object where you can access the data items. For example, if you provide a handler for the pageLoading event, the custom data is passed with the PageLoadingEventArgs object, which exposes a dataItems property.

Examples

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 of an UpdatePanel control. Additionally, this example demonstrates the overload that does not take the isJsonSerialized parameter. Otherwise, the procedure for retrieving the dataItems property of the PageLoadingEventArgs object is the same.

note

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 of an UpdatePanel control.

Exceptions

ExceptionCondition
ArgumentNullException

control is null.

InvalidOperationException

The RegisterDataItem method is called during a postback.

ArgumentException

dataItem is already registered for control.

Assembly: System.Web.Extensions (Module: System.Web.Extensions)