Page.RegisterArrayDeclaration(String, String) Method

Definition

Caution

The recommended alternative is ClientScript.RegisterArrayDeclaration(string arrayName, string arrayValue). http://go.microsoft.com/fwlink/?linkid=14202

Declares a value that is declared as an ECMAScript array declaration when the page is rendered.

public void RegisterArrayDeclaration(string arrayName, string arrayValue);
[System.Obsolete("The recommended alternative is ClientScript.RegisterArrayDeclaration(string arrayName, string arrayValue). http://go.microsoft.com/fwlink/?linkid=14202")]
public void RegisterArrayDeclaration(string arrayName, string arrayValue);

Parameters

arrayName
String

The name of the array in which to declare the value.

arrayValue
String

The value to place in the array.

Attributes

Examples

The following code example uses the RegisterArrayDeclaration method to declare an array, myArray, that contains three objects named x, y, and z. The example defines and registers a startup script using the RegisterStartupScript method. When the ECMAScript doClick function is called from the page that contains this code, the array and its objects are initialized.

void Page_Load(Object sender, EventArgs e) 
{ 
   String scriptString = "<script language=\"JavaScript\"> function doClick() {";
   scriptString += "for(var index=0;index < myArray.length;index++)";
   scriptString += " myArray[index].show(); } <";
   scriptString += "/" + "script>";
     
   RegisterStartupScript("arrayScript", scriptString); 
   RegisterArrayDeclaration("myArray", "new obj('x'),new obj('y'),new obj('z')"); 
} 

Remarks

This method can be used by script-based controls to declare themselves within an array so that a client script library can work with all the controls of the same type.

The RegisterArrayDeclaration method has been deprecated. Use the RegisterArrayDeclaration method in the ClientScriptManager class.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also