ScriptManager.Scripts 属性

定义

获取一个 ScriptReferenceCollection 对象,该对象包含 ScriptReference 对象,每个对象表示呈现给客户端的脚本文件。

public:
 property System::Web::UI::ScriptReferenceCollection ^ Scripts { System::Web::UI::ScriptReferenceCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.ScriptReferenceCollection Scripts { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.Scripts : System.Web.UI.ScriptReferenceCollection
Public ReadOnly Property Scripts As ScriptReferenceCollection

属性值

实例 ScriptReferenceCollection 的对象 ScriptManager

属性

注解

ScriptReferenceCollection此属性返回的对象是对象的集合ScriptReference,每个对象表示脚本文件。 该集合包括对 ASP.NET Ajax 功能所需的所有脚本文件的引用,以及对自定义脚本文件的引用。 可在控件或关联ScriptManager控件中定义要呈现的ScriptManagerProxy自定义脚本文件。

可以通过将元素添加到页面上元素内的asp:ScriptReference节点,将脚本文件添加到Scripts标记asp:ScriptManager中的集合,如以下示例所示。

<asp:ScriptManager ID="SM1" runat="server">
  <Scripts>
    <asp:ScriptReference Name="Script.js" />
  </Scripts>
</asp:ScriptManager>

还可以使用ScriptReference类的方法Scripts以编程方式将对象添加到AddScriptReferenceCollection集合中。

控件 ScriptManager 在控件 PreRender 的事件期间注册脚本文件。

Scripts 集合不包含 Ajax 库脚本的核心Microsoft。 核心库中的脚本会自动呈现;无需向 ScriptManager 控件注册它们。 但是,如果要重写核心脚本或任何控件脚本,并替换不同版本的脚本,则可以将 Scripts 版本添加到集合中。

适用于