Export (0) Print
Expand All

ScriptManager.Scripts Property

Gets a ScriptReferenceCollection object that contains the ScriptReference objects, each of which represents a script file rendered to the client.

Namespace:  System.Web.UI
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
public ScriptReferenceCollection Scripts { get; }

The ScriptReferenceCollection object that is returned by this property is a collection of ScriptReference objects, each of which represents a script file. The collection includes references to all the script files that ASP.NET needs for Ajax functionality, and to custom script files. Custom script files to render can be defined in the ScriptManager control or in an associated ScriptManagerProxy control.

You can add script files to the collection in markup by adding asp:ScriptReference elements to a Scripts node inside the asp:ScriptManager element on the page, as shown in the following example.

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

You can also add a ScriptReference object to the Scripts collection programmatically by using the Add method of the ScriptReferenceCollection class.

The ScriptManager control registers script files during the control's PreRender event.

The Scripts collection does not contain the core Microsoft Ajax Library scripts. The scripts in the core library are rendered automatically; they do not have to be registered with the ScriptManager control. However, if you want to override a core script or any control script and substitute a different version of the script, you can add your version to the Scripts collection.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft