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.

public:
 void RegisterArrayDeclaration(System::String ^ arrayName, System::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);
member this.RegisterArrayDeclaration : string * string -> unit
Public Sub RegisterArrayDeclaration (arrayName As String, arrayValue As String)

參數

arrayName
String String String String

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

arrayValue
String String String String

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

範例

下列程式碼範例會使用RegisterArrayDeclaration方法來宣告陣列, myArray其中包含三個名為xyz的物件。The 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. 從包含此doClick程式碼的頁面呼叫 ECMAScript 函式時,會初始化陣列及其物件。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方法 ClientScriptManagerUse the RegisterArrayDeclaration method in the ClientScriptManager class.

適用於

另請參閱