更新:2007 年 11 月
ASP.NET 中的 AJAX 功能有助于創(chuàng)建客戶端腳本并將其集成到 ASP.NET 應(yīng)用程序中。這包括 ECMAScript (JavaScript) 的類型系統(tǒng)以及為現(xiàn)有 ECMAScript (JavaScript) 對象提供豐富的 .NET Framework 類的擴(kuò)展。ASP.NET 還包括 ScriptManager 控件,此控件可用于管理這些腳本庫以及應(yīng)用程序中的任何自定義腳本。
本主題包含以下部分:

當(dāng)您要執(zhí)行下列操作時,可以使用 Microsoft AJAX Library 的功能:
-
向 JavaScript 代碼中添加面向?qū)ο蟮墓δ埽蕴岣叽a的重用性、靈活性和可維護(hù)性。
-
使用反射在運(yùn)行時檢查客戶端腳本的結(jié)構(gòu)和組件。
-
使用枚舉提供不同于整數(shù)的另一種易讀的表示形式。
-
使用 JavaScript 基類型的擴(kuò)展縮短常規(guī)腳本任務(wù)的開發(fā)時間。
-
使用調(diào)試擴(kuò)展和跟蹤功能,實(shí)現(xiàn)比傳統(tǒng) JavaScript 調(diào)試技術(shù)更快、信息更豐富的調(diào)試。

Microsoft AJAX Library 增加了一個類型系統(tǒng)以及一系列對 JavaScript 對象的擴(kuò)展,可提供與 .NET Framework 功能類似的面向?qū)ο蟮某S霉δ?。利用這些功能,可按一種結(jié)構(gòu)化方式編寫支持 AJAX 的 ASP.NET 應(yīng)用程序,這不僅能提高可維護(hù)性,還簡化了添加功能以及對功能分層的操作。Microsoft AJAX Library 擴(kuò)展為 JavaScript 添加了下列功能:
-
類
-
命名空間
-
繼承
-
接口
-
枚舉
-
反射
該庫還提供了針對字符串和數(shù)組的 Helper 函數(shù)。
類、成員和命名空間
Microsoft AJAX Library 包括基類及其派生的對象和組件。通過所有這些類,您可以使用面向?qū)ο蟮木幊棠P蛠砭帉懣蛻舳四_本。
Type 類為 JavaScript 編程添加了命名空間、類和繼承等面向?qū)ο蟮墓δ?。任何使?Type 類注冊的 JavaScript 對象都會自動獲得訪問此功能的權(quán)限。下面的示例演示如何使用 Type 類在 JavaScript 文件中創(chuàng)建并注冊一個命名空間和類:
Type.registerNamespace("Demo");Demo.Person = function(firstName, lastName, emailAddress) {this._firstName = firstName;this._lastName = lastName;this._emailAddress = emailAddress;}Demo.Person.prototype = {getFirstName: function() {return this._firstName;},getLastName: function() {return this._lastName;},getName: function() {return this._firstName + ' ' + this._lastName;},dispose: function() {alert('bye ' + this.getName());}}Demo.Person.registerClass('Demo.Person', null, Sys.IDisposable);// Notify ScriptManager that this is the end of the script.if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
類有四種成員:字段、屬性、方法和事件。字段和屬性是名稱/值對,用于描述類實(shí)例的特征。字段由基元類型組成,可直接進(jìn)行訪問,如下面的示例所示:
myClassInstance.name="Fred"
屬性可以表示任何基元類型或引用類型。屬性值需通過 get 和 set 訪問器方法進(jìn)行訪問。在 Microsoft AJAX Library 中,get 和 set 訪問器都是函數(shù)。按照約定,這些函數(shù)的名稱中應(yīng)使用前綴“get_”或“set_”。例如,若要獲取或設(shè)置屬性 cancel 的值,需要調(diào)用 get_cancel 或 set_cancel 方法。
對于在 AJAX 客戶端應(yīng)用程序生命周期中發(fā)生的操作,Microsoft AJAX Library 將引發(fā)相應(yīng)的事件進(jìn)行響應(yīng)。Microsoft AJAX Library 還提供一種為 AJAX 客戶端組件創(chuàng)建自定義事件的標(biāo)準(zhǔn)方式。有關(guān)更多信息,請參見創(chuàng)建自定義客戶端事件和 AJAX 客戶端生命周期事件。
Microsoft AJAX Library 提供一種有助于對常用功能進(jìn)行分組的命名空間注冊方式。下面的示例演示如何使用 Type.registerNamespace 和 .registerClass 方法向 Demo 命名空間中添加 Person 類。
若要對 ASP.NET 網(wǎng)頁啟用 AJAX 功能,必須向該頁面添加 ScriptManager 控件。呈現(xiàn)該頁面時,將自動生成對 AJAX 客戶端腳本庫的相應(yīng)腳本引用。下面的示例演示一個包含 ScriptManager 控件的頁面。
<asp:ScriptManager runat="server" ID="scriptManager" />
下面的示例演示如何完成以下過程:注冊命名空間,創(chuàng)建類,然后重新注冊該類。
Type.registerNamespace("Demo");Demo.Person = function(firstName, lastName, emailAddress) {this._firstName = firstName;this._lastName = lastName;this._emailAddress = emailAddress;}Demo.Person.prototype = {getFirstName: function() {return this._firstName;},getLastName: function() {return this._lastName;},getName: function() {return this._firstName + ' ' + this._lastName;},dispose: function() {alert('bye ' + this.getName());}}Demo.Person.registerClass('Demo.Person', null, Sys.IDisposable);// Notify ScriptManager that this is the end of the script.if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head><title>Namespace</title></head><body><form id="Main" runat="server"><asp:ScriptManager runat="server" ID="scriptManager" /></form><div><p>This example creates an instance of the Person classand puts it in the "Demo" namespace.</p><input id="Button1" value="Create Demo.Person"type="button" onclick="return OnButton1Click()" /></div><script type="text/javascript" src="Namespace.js"></script><script type="text/javascript" language="JavaScript">function OnButton1Click(){var testPerson = new Demo.Person('John', 'Smith', 'john.smith@example.com');alert(testPerson.getFirstName() + " " +testPerson.getLastName() );return false;}</script></body></html>
訪問修飾符
大多數(shù)面向?qū)ο蟮木幊陶Z言都包括“訪問修飾符”這一概念。通過訪問修飾符,可以指定類或成員可用的上下文,例如是對外部程序可用,還是對同一命名空間中的內(nèi)部類可用,抑或是僅在特定的代碼塊中可用。JavaScript 中沒有訪問修飾符。但是,Microsoft AJAX Library 遵循以下約定:名稱以下劃線字符(“_”)開頭的成員視為私有成員,不能從成員所屬類的外部訪問它們。
繼承
繼承是指一個類從另一個類派生的能力。派生類可自動繼承基類的所有字段、屬性、方法和事件。派生類可以添加新成員或者重寫基類的現(xiàn)有成員,以更改這些成員的行為。
下面的示例包含兩個在腳本中定義的類:Person 和 Employee,其中 Employee 派生自 Person。這兩個類演示私有字段的用法,并且它們都具有公共屬性和方法。此外,Employee 還重寫 Person 類的 toString 實(shí)現(xiàn)并使用基類的功能。
Type.registerNamespace("Demo");Demo.Person = function(firstName, lastName, emailAddress) {this._firstName = firstName;this._lastName = lastName;this._emailAddress = emailAddress;}Demo.Person.prototype = {getFirstName: function() {return this._firstName;},getLastName: function() {return this._lastName;},getEmailAddress: function() {return this._emailAddress;},setEmailAddress: function(emailAddress) {this._emailAddress = emailAddress;},getName: function() {return this._firstName + ' ' + this._lastName;},dispose: function() {alert('bye ' + this.getName());},sendMail: function() {var emailAddress = this.getEmailAddress();if (emailAddress.indexOf('@') < 0) {emailAddress = emailAddress + '@example.com';}alert('Sending mail to ' + emailAddress + ' ...');},toString: function() {return this.getName() + ' (' + this.getEmailAddress() + ')';}}Demo.Person.registerClass('Demo.Person', null, Sys.IDisposable);Demo.Employee = function(firstName, lastName, emailAddress, team, title) {Demo.Employee.initializeBase(this, [firstName, lastName, emailAddress]);this._team = team;this._title = title;}Demo.Employee.prototype = {getTeam: function() {return this._team;},setTeam: function(team) {this._team = team;},getTitle: function() {return this._title;},setTitle: function(title) {this._title = title;},toString: function() {return Demo.Employee.callBaseMethod(this, 'toString') + '\r\n' + this.getTitle() + '\r\n' + this.getTeam();}}Demo.Employee.registerClass('Demo.Employee', Demo.Person);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head><title>Inheritance</title></head><body><form id="Main" runat="server"><asp:ScriptManager runat="server" ID="scriptManager" /><script type="text/javascript" src="Inheritance.js"></script></form><h2>Inheritance</h2><p /><div>This file contains two classes defined in script: Person and Employee, whereEmployee derives from Person.<p />Each class has private fields, and public properties and methods. In addition,Employee overrides the toString implementation, and in doing so, it uses thebase class functionality.<p />This example puts the Person class in the "Demo" namespace.<p /></div><div><ul><li><a href="#" onclick="return OnTestNewClick()">Object Creation</a></li><li><a href="#" onclick="return OnTestDisposeClick()">Object Dispose</a></li><li><a href="#" onclick="return OnTestPrivatePropertyClick()">Public vs. Private Properties</a></li><li><a href="#" onclick="return OnTestInstanceMethodClick()">Instance Methods</a></li><li><a href="#" onclick="return OnTestOverrideMethodClick()">Overriden Methods</a></li><li><a href="#" onclick="return OnTestInstanceOfClick()">Instance Of Check</a></li></ul></div><script type="text/javascript" language="JavaScript">function GetTestPerson(){return new Demo.Person('Jane', 'Doe', 'jane.doe@example.com');}function GetTestEmployee(){return new Demo.Employee('John', 'Doe', 'john.doe@example.com', 'Platform', 'Programmer');}function OnTestNewClick() {var aPerson = GetTestPerson();alert(aPerson.getFirstName());alert(aPerson);alert(Object.getType(aPerson).getName());var testPerson = GetTestPerson();alert(testPerson.getFirstName());alert(testPerson);return false;}function OnTestDisposeClick() {var aPerson = GetTestEmployee();alert(aPerson.getFirstName());aPerson.dispose();}function OnTestPrivatePropertyClick() {var aPerson = GetTestEmployee();alert('aPerson._firstName = ' + aPerson._firstName);alert('aPersona.getFirstName() = ' + aPerson.getFirstName());return false;}function OnTestInstanceMethodClick() {var aPerson = GetTestEmployee();aPerson.sendMail('Hello', 'This is a test mail.');return false;}function OnTestOverrideMethodClick() {var testPerson = GetTestEmployee();alert(testPerson);return false;}function OnTestInstanceOfClick() {var aPerson = GetTestEmployee();if (Demo.Employee.isInstanceOfType(aPerson)) {alert(aPerson.getName() + ' is an Employee instance.\r\nTitle property: ' + aPerson.getTitle());}return false;}</script></body></html>
接口
接口用于定義實(shí)現(xiàn)它的類的輸入和輸出要求。這樣,函數(shù)可以和實(shí)現(xiàn)同一接口的類進(jìn)行交互,而不用考慮該類還實(shí)現(xiàn)哪些其他功能。
下面的示例定義一個 Tree 基類和一個 IFruitTree 接口。兩個派生類 Apple 和 Banana 可實(shí)現(xiàn) IFruitTree 接口,但 Pine 類不實(shí)現(xiàn)該接口。實(shí)現(xiàn) IFruitTree 接口的任何類都可確保 bearFruit 方法是該類的成員。
Type.registerNamespace("Demo.Trees");Demo.Trees.IFruitTree = function() {}Demo.Trees.IFruitTree.Prototype = {bearFruit: function(){}}Demo.Trees.IFruitTree.registerInterface('Demo.Trees.IFruitTree');Demo.Trees.Tree = function(name) {this._name = name;}Demo.Trees.Tree.prototype = {returnName: function() {return this._name;},toStringCustom: function() {return this.returnName();},makeLeaves: function() {}}Demo.Trees.Tree.registerClass('Demo.Trees.Tree');Demo.Trees.FruitTree = function(name, description) {Demo.Trees.FruitTree.initializeBase(this, [name]);this._description = description;}Demo.Trees.FruitTree.prototype.bearFruit = function() {return this._description;}Demo.Trees.FruitTree.registerClass('Demo.Trees.FruitTree', Demo.Trees.Tree, Demo.Trees.IFruitTree);Demo.Trees.Apple = function() {Demo.Trees.Apple.initializeBase(this, ['Apple', 'red and crunchy']);}Demo.Trees.Apple.prototype = {makeLeaves: function() {alert('Medium-sized and desiduous');},toStringCustom: function() {return 'FruitTree ' + Demo.Trees.Apple.callBaseMethod(this, 'toStringCustom');}}Demo.Trees.Apple.registerClass('Demo.Trees.Apple', Demo.Trees.FruitTree);Demo.Trees.GreenApple = function() {Demo.Trees.GreenApple.initializeBase(this);// You must set the _description feild after initializeBase// or you will get the base value.this._description = 'green and sour';}Demo.Trees.GreenApple.prototype.toStringCustom = function() {return Demo.Trees.GreenApple.callBaseMethod(this, 'toStringCustom') + ' ... its GreenApple!';}Demo.Trees.GreenApple.registerClass('Demo.Trees.GreenApple', Demo.Trees.Apple);Demo.Trees.Banana = function(description) {Demo.Trees.Banana.initializeBase(this, ['Banana', 'yellow and squishy']);}Demo.Trees.Banana.prototype.makeLeaves = function() {alert('Big and green');}Demo.Trees.Banana.registerClass('Demo.Trees.Banana', Demo.Trees.FruitTree);Demo.Trees.Pine = function() {Demo.Trees.Pine.initializeBase(this, ['Pine']);}Demo.Trees.Pine.prototype.makeLeaves = function() {alert('Needles in clusters');}Demo.Trees.Pine.registerClass('Demo.Trees.Pine', Demo.Trees.Tree);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head><title>Interface</title></head><body><form id="Main" runat="server"><asp:ScriptManager runat="server" ID="scriptManager" /></form><h2>Interface</h2><p /><div>This file contains a Tree base class, and an IFruitTree interface.Apple and Banana, two derived classes implement that interface, whereas,Pine does not implement that interface.<p /></div><script type="text/javascript" src="Interface.js"></script><div><ul><li><a href="#" onclick="return OnTestNewClick()">Object Creation</a></li><li><a href="#" onclick="return OnTestImplementsClick()">Implements Check</a></li><li><a href="#" onclick="return OnTestInterfaceMethodClick()">Call interface method</a></li></ul></div><script type="text/javascript" language="JavaScript">function OnTestNewClick() {var apple = new Demo.Trees.Apple('Apple');alert(apple.returnName());apple.makeLeaves();return false;}function OnTestImplementsClick() {var apple = new Demo.Trees.Apple();if (Demo.Trees.IFruitTree.isImplementedBy(apple)) {alert('Apple implements IFruitTree');}else {alert('Apple does not implement IFruitTree');}var pine = new Demo.Trees.Pine();if (Demo.Trees.IFruitTree.isImplementedBy(pine)) {alert('Pine implements IFruitTree');}else {alert('Pine does not implement IFruitTree');}return false;}function OnTestInterfaceMethodClick() {var apple = new Demo.Trees.Apple();ProcessTree(apple);var pine = new Demo.Trees.Pine();ProcessTree(pine);var banana = new Demo.Trees.Banana();ProcessTree(banana);var g = new Demo.Trees.GreenApple();ProcessTree(g);return false;}function ProcessTree(tree) {alert('Current Tree ' + tree.returnName());alert(tree.toStringCustom());if (Demo.Trees.IFruitTree.isImplementedBy(tree)) {alert(tree.returnName() + ' implements IFruitTree; Fruit is ' + tree.bearFruit());}}</script></body></html>
枚舉
枚舉是指包含一組命名整數(shù)常量的類。您可以像訪問屬性那樣訪問這些值,如下面的示例所示:
myObject.color = myColorEnum.red
枚舉提供不同于整數(shù)的另一種易讀的表示形式。有關(guān) Microsoft AJAX Library 中的枚舉的更多信息,請參見 Type.registerEnum 方法 (ASP.NET AJAX)。
下面的示例定義一個命名顏色的枚舉,這些命名顏色用于表示十六進(jìn)制的值。
Type.registerNamespace("Demo");// Define an enumeration type and register it.Demo.Color = function(){};Demo.Color.prototype ={Red: 0xFF0000,Blue: 0x0000FF,Green: 0x00FF00,White: 0xFFFFFF}Demo.Color.registerEnum("Demo.Color");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head><title>Enumeration</title></head><body><form id="Main" runat="server"><asp:ScriptManager runat="server" ID="scriptManager" /></form><div><p>This example creates an Enumeration of colorsand applies them to page background.</p><select id="ColorPicker"onchange="ChangeColor(options[selectedIndex].value)"><option value="Red" label="Red" /><option value="Blue" label="Blue" /><option value="Green" label="Green" /><option value="White" label="White" /></select></div><script type="text/javascript" src="Enumeration.js"></script><script type="text/javascript" language="JavaScript">function ChangeColor(value){document.body.bgColor = eval("Demo.Color." + value + ";");}</script></body></html>
反射
反射是指在運(yùn)行時檢查程序的結(jié)構(gòu)和組件的能力。實(shí)現(xiàn)反射的 API 是對 Type 類的擴(kuò)展。通過這些方法,可以收集有關(guān)對象的信息,例如該對象繼承自誰,它是否實(shí)現(xiàn)特定的接口,以及它是否是特定類的實(shí)例等。
下面的示例使用反射 API 對前面接口示例中的 GreenApple 類進(jìn)行測試。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head><title>Reflection</title></head><body><form id="Main" runat="server"><asp:ScriptManager runat="server" ID="scriptManager" /></form><div><p>This example tests the Demo.Trees.GreenApple classagainst various reflection APIs.</p><input id="Button1" value="Check Type"type="button" onclick="return OnButton1Click()" /><input id="Button2" value="Check Inheritance"type="button" onclick="return OnButton2Click()" /><input id="Button3" value="Check Interface"type="button" onclick="return OnButton3Click()" /></div><script type="text/javascript" src="Interface.js"></script><script type="text/javascript" language="JavaScript">var g = new Demo.Trees.GreenApple();var gt = Demo.Trees.GreenApple;var a = new Array(Demo.Trees.Apple,Demo.Trees.Tree,Demo.Trees.Pine,Demo.Trees.IFruitTree,Sys.IContainer);function OnButton1Click(){for (var i = 0; i < a.length; i ++){if (a[i].isInstanceOfType(g)){alert(gt.getName() + " is a " + a[i].getName() + ".");}else alert(gt.getName() + " is not a " + a[i].getName() + ".");}}function OnButton2Click(){for (var i = 0; i < a.length; i ++){if (gt.inheritsFrom(a[i])){alert(gt.getName() + " inherits from " + a[i].getName() + ".");}else alert(gt.getName() + " does not inherit from " + a[i].getName() + ".");}}function OnButton3Click(){for (var i = 0; i < a.length; i ++){if (Type.isInterface(a[i])){if (gt.implementsInterface(a[i])){alert(gt.getName() + " implements the " + a[i].getName() + " interface.");}else alert(gt.getName() + " does not implement the " + a[i].getName() + " interface.");}else alert(a[i].getName() + " is not an interface.");}}</script></body></html>

JavaScript 基類型的擴(kuò)展可為這些類型提供附加功能。有關(guān)這些擴(kuò)展的更多信息,請參見下列主題:
Sys.Debug 類可提供豐富的調(diào)試功能。有關(guān)更多信息,請參見 調(diào)試和跟蹤 AJAX 應(yīng)用程序概述和 Sys.Debug 類概述。
如果基于 Microsoft AJAX Library 創(chuàng)建組件,則可以創(chuàng)建由 ScriptManager 控件自動管理的腳本文件的調(diào)試版本和發(fā)行版本。通過在腳本文件名中添加“.debug”部分,可以標(biāo)識腳本文件的調(diào)試版本。例如,下面的腳本文件名標(biāo)識同一文件的零售版本和調(diào)試版本:
-
MyScript.js(零售版)
-
MyScript.debug.js(調(diào)試版)

任何 ASP.NET 網(wǎng)頁均可以通過在 <script> 塊中引用腳本文件來對其進(jìn)行訪問,如下面的示例所示:
<script type="text/javascript" src="MyScript.js"></script>
但是,以此方式調(diào)用的腳本將不能參與部分頁呈現(xiàn),或無法訪問 Microsoft AJAX Library 的某些組件。若要使腳本文件可在支持 AJAX 的 ASP.NET Web 應(yīng)用程序中用于部分頁呈現(xiàn),必須在該頁面的 ScriptManager 控件中注冊該腳本。若要注冊腳本文件,請創(chuàng)建一個指向相關(guān)文件的 ScriptReference 對象,并使之將該文件添加到 Scripts 集合中。下面的示例演示如何在標(biāo)記中執(zhí)行此操作:
<asp:ScriptManager ID="SMgr" runat="server"><Scripts><asp:ScriptReference path="MyScript.js" /></Scripts></asp:ScriptManager>
若要使腳本文件得到 ScriptManager 控件的正確處理,每個文件都必須在末尾包含對 Sys.Application.notifyScriptLoaded 方法的調(diào)用。此調(diào)用可通知應(yīng)用程序,已完成文件加載。下面的示例演示用于實(shí)現(xiàn)此目的的代碼:
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
此外,您還可以將 .js 文件作為資源嵌入在托管代碼程序集中(如果創(chuàng)建的 ASP.NET 服務(wù)器控件在客戶端腳本中實(shí)現(xiàn)其 AJAX 功能,則可能需要這樣做)。將腳本嵌入在程序集中時,腳本中便無需包括通知語句。此外,您也不必在腳本引用中指定 path 屬性。但是,必須提供不帶文件擴(kuò)展名的程序集名稱,如下面的示例所示:
<asp:ScriptManager ID="SMgr" runat="server"><Scripts><asp:ScriptReferenceName="MyScript.js" Assembly="MyScriptAssembly"/></Scripts></asp:ScriptManager>
![]() |
---|
對頁面開發(fā)人員而言,此情況并不常見,因?yàn)榍队心_本庫的大多數(shù)控件都會從內(nèi)部引用其腳本。有關(guān)更多信息,請參見 演練:將 JavaScript 文件作為資源嵌入到程序集中。 |
此外,通過在代碼中創(chuàng)建腳本引用并將它們添加到 Scripts 集合中,還可以用編程方式注冊腳本。有關(guān)更多信息,請參見 動態(tài)分配腳本引用。
使用 ScriptManager 控件的注冊方法,可以注冊部分頁更新所需的腳本。您可以按下列方式使用這些方法:
-
若要在代碼中生成客戶端腳本,請以字符串形式生成一個腳本塊,然后將其傳遞給 RegisterClientScriptBlock 方法。
-
若要添加沒有 Microsoft AJAX Library 依賴項(xiàng)的獨(dú)立腳本文件,請使用 RegisterClientScriptInclude 方法。
-
若要添加嵌入在程序集中的腳本文件,請使用 RegisterClientScriptInclude 方法。
說明:使用這些方法注冊的腳本不具有本地化支持。
有關(guān)腳本注冊方法的完整列表及其用法,請參見 ScriptManager 控件概述。
任何要注冊的腳本塊或內(nèi)聯(lián)腳本都必須位于頁面的 <form> 元素中。否則,該腳本將不能在 ScriptManager 控件中注冊,從而無法訪問 ASP.NET AJAX 功能。有關(guān)更多信息,請參見 Sys.Application.initialize 方法。