Page.RegisterArrayDeclaration(String, String) Page.RegisterArrayDeclaration(String, String) Page.RegisterArrayDeclaration(String, String) Page.RegisterArrayDeclaration(String, String) Method



此 API 現已淘汰。

宣告在呈現頁面時宣告為 ECMAScript 陣列宣告的值。Declares a value that is declared as an ECMAScript array declaration when the page is rendered.

 void RegisterArrayDeclaration(System::String ^ arrayName, System::String ^ arrayValue);
[System.Obsolete("The recommended alternative is ClientScript.RegisterArrayDeclaration(string arrayName, string arrayValue).")]
public void RegisterArrayDeclaration (string arrayName, string arrayValue);
member this.RegisterArrayDeclaration : string * string -> unit
Public Sub RegisterArrayDeclaration (arrayName As String, arrayValue As String)


String String String String

陣列名稱,要在其中宣告數值。The name of the array in which to declare the value.

String String String String

要在陣列中放置的值。The value to place in the array.


下列程式碼範例會使用RegisterArrayDeclaration方法,以將陣列中,宣告myArray,,其中包含三個名為的物件xy,和zThe following code example uses the RegisterArrayDeclaration method to declare an array, myArray, that contains three objects named x, y, and z. 此範例定義,並註冊啟動指令碼使用RegisterStartupScript方法。The example defines and registers a startup script using the RegisterStartupScript method. 當 ECMAScriptdoClick函式由包含此程式碼的頁面呼叫、 陣列和其物件會初始化。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')"); 

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


這個方法可供指令碼為基礎的控制項,如此用戶端指令碼程式庫能與相同類型的所有控制項陣列中宣告本身。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.

RegisterArrayDeclaration 方法已被取代。The RegisterArrayDeclaration method has been deprecated. 使用RegisterArrayDeclaration方法中的ClientScriptManager類別。Use the RegisterArrayDeclaration method in the ClientScriptManager class.