This documentation is archived and is not being maintained.

Page.RegisterArrayDeclaration Method

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

[Visual Basic]
Public Sub RegisterArrayDeclaration( _
   ByVal arrayName As String, _
   ByVal arrayValue As String _
public void RegisterArrayDeclaration(
 string arrayName,
 string arrayValue
public: void RegisterArrayDeclaration(
 String* arrayName,
 String* arrayValue
public function RegisterArrayDeclaration(
   arrayName : String,
 arrayValue : String


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


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.


[Visual Basic, C#] The following example uses the RegisterArrayDeclaration method to declare and 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 JavaScript doClick function is called from the page that contains this code, the array and its objects are initialized.

[Visual Basic] 

 Dim scriptString As String = "<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')")

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')"); 

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Page Class | Page Members | System.Web.UI Namespace