Export (0) Print
Expand All
Expand Minimize
1 out of 1 rated this helpful - Rate this topic

Page.RegisterArrayDeclaration Method

NOTE: This method is now obsolete.

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

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
[ObsoleteAttribute("The recommended alternative is ClientScript.RegisterArrayDeclaration(string arrayName, string arrayValue). http://go.microsoft.com/fwlink/?linkid=14202")] 
public void RegisterArrayDeclaration (
	string arrayName,
	string arrayValue
)
/** @attribute ObsoleteAttribute("The recommended alternative is ClientScript.RegisterArrayDeclaration(string arrayName, string arrayValue). http://go.microsoft.com/fwlink/?linkid=14202") */ 
public void RegisterArrayDeclaration (
	String arrayName, 
	String arrayValue
)
ObsoleteAttribute("The recommended alternative is ClientScript.RegisterArrayDeclaration(string arrayName, string arrayValue). http://go.microsoft.com/fwlink/?linkid=14202") 
public function RegisterArrayDeclaration (
	arrayName : String, 
	arrayValue : String
)
Not applicable.

Parameters

arrayName

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

arrayValue

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.

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

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

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

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 1.0, 1.1, 2.0
Obsolete (compiler warning) in 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.