ScriptManager.ScriptResourceMapping Property

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets a ScriptResourceMapping object.

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

Public Shared ReadOnly Property ScriptResourceMapping As ScriptResourceMapping

The static ScriptResourceMapping property returns a ScriptResourceMapping object that can contain a collection of mappings that represent the location of the script resource (script redirection). This collection of mappings can be mapped based on names or name/assembly pairs, and it can point to a ScriptResourceDefinition object.

The following examples shows how to add a ScriptResourceDefinition object that can be referenced by a ScriptManager object. Add the following code to the Global.asax file in the Application_Start event.

Dim myScriptResDef As New ScriptResourceDefinition()
myScriptResDef.Path = "~/Scripts/jquery-1.4.2.min.js"
myScriptResDef.DebugPath = "~/Scripts/jquery-1.4.2.js"
myScriptResDef.CdnPath = ""
myScriptResDef.CdnDebugPath = ""
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", Nothing, myScriptResDef)

In the markup for an ASP.NET Web Forms page (.aspx file), add the following markup inside the form element and before any elements or code that uses jQuery script.

<asp:ScriptManager ID="sm1" runat="server">
    <asp:ScriptReference Name="jquery"/>

.NET Framework
Available since 4.0
Return to top