asp.net ajax
******************************************************************************************
Integrating Client Script into ASP.NET Web Applications
Any ASP.NET Web page can access a script file by referring to it in a <script> block, as in the following example:
<script type="text/javascript" src="MyScript.js"></script>However, a script invoked in this manner cannot participate(take part in wp.) in partial-page rendering or access certain components of the Microsoft AJAX Library. To make a script file available for partial-page rendering in an ASP.NET AJAX Web application, the script must be registered with the ScriptManager control on the page. To register a script file, create a ScriptReference object that points to the file question and that adds it to the Scripts collection. The following example shows how to do this in markup:
<asp:ScriptManager ID="SMgr" runat="server">
<Scripts>
<asp:ScriptReference path="MyScript.js" />
</Scripts>
</asp:ScriptManager> For script files to be processed correctly by the ScriptManager control, each file (Maybe should be each js file wp.)must include a call to the Sys.Application.notifyScriptLoaded method at the end of the file. This call notifies the application that the file has finished loading. The following example shows the code to use for this purpose:
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();If your script is embedded in an assembly, you do not have to include a notification statement in the script. You also do not have to specify a path attribute in the script reference. However, you must provide the name of the assembly without the file name extension, as shown in the following example:
<asp:ScriptManager ID="SMgr" runat="server">
<Scripts>
<asp:ScriptReference
Name="MyScript.js" Assembly="MyScriptAssembly"/>
</Scripts>
</asp:ScriptManager> This scenario is not common for page developers, because most controls with embedded script libraries reference their scripts internally. For more information, see Embedding a JavaScript File as a Resource in an Assembly.
You can also register scripts programmatically by creating script references in code and then adding them to the Scripts collection. For more information, see Dynamically Assigning ASP.NET AJAX Script References.
You can register scripts that are required for partial-page updates by using the registration methods of the ScriptManager control. You can use these methods in the following ways:
To generate client script in code, build a block of script as a string and pass it to the RegisterClientScriptBlock) method.
To add standalone script files that have no Microsoft AJAX Library dependencies, use the RegisterClientScriptInclude) method.
To add script files that are embedded in an assembly, use the RegisterClientScriptResource method.
Scripts that are registered by using these methods do not have localization support.
For a complete list of script-registration methods and their uses, see the ScriptManager control overview.
Any script blocks or inline script that you are registering must be inside the page's <form> element. Otherwise, the script is not registered with the ScriptManager control and cannot access ASP.NET AJAX functionality. For more information, see initialize Method.
浙公网安备 33010602011771号