ScriptManager 脚本引用有什么作用?

What does a ScriptManager script reference do?

在我之前从事的项目中,我注意到 javascript 文件包含在脚本管理器中,如下所示:

 <asp:ScriptReference Path="~/Scripts/jquery-1.7.1.min.js" />
 <asp:ScriptReference Path="~/Scripts/site.js" />

我尝试在 asp 页面中搜索脚本参考和常规 <script src="/> 之间的区别,但似乎找不到任何信息。使用脚本参考有优势吗?

谢谢

当您使用 ScriptManager 时,可以创建一个复合脚本来减少浏览器请求的数量 ASP.NET。

也可以参考ScriptReference Class

此外,ScriptManager 的 about 部分详细介绍了有关 它:

ScriptManager is an ASP.NET control that manages ASP.NET Ajax script libraries. The ScriptManager performs the following functions.

  1. Enables partial page rendering
  2. Eanbles client side script access to web services
  3. Enables use of authenication and profile services from the client

Only one ScriptManager can be allowed per page. For scenarios where a second ScriptManager reference is required, such as within an usercontrol, the ScriptManagerProxy control should be used.