ClientScriptManager.RegisterArrayDeclaration Method (String, String)


Registers a JavaScript array declaration with the Page object using an array name and array value.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

member RegisterArrayDeclaration : 
        arrayName:string *
        arrayValue:string -> unit


Type: System.String

The array name to register.

Type: System.String

The array value or values to register.

Exception Condition

arrayName is null.

The RegisterArrayDeclaration checks to see whether a registered array exists with the same name as the name specified in the arrayName parameter and, if so, adds the values specified in the arrayValue parameter. Because the underlying storage mechanism is based on an ArrayList, duplicates are allowed. If a registered array with the same name as the arrayName parameter does not exist, it is created and the values in the arrayValue parameter added to it.

If you want string literals in the resulting JavaScript array, include single quotation marks (') or escaped double quotation marks (\") in the arrayValue parameter. The value of the arrayValue parameter should be a single element. If more than one value needs to be added to the array, make multiple calls using the RegisterArrayDeclaration method.

The following code example demonstrates the use of the RegisterArrayDeclaration and RegisterHiddenField methods. The example registers an array and a hidden value and defines the OnClick event of an <input> button to calculate the sum of two values of the array and the hidden value.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top