This documentation is archived and is not being maintained.

ScriptReferenceEventArgs Class

Provides data for the ResolveScriptReference event.

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

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ScriptReferenceEventArgs : EventArgs

When a script reference is rendered, the ScriptReferenceEventArgs object contains the ScriptReference object that is defined in the ScriptManager instance. You can create an event handler for the ResolveScriptReference event to check the ScriptReference object and modify it as needed.

The following example shows an ASP.NET Web page that references a script file that is named CustomScript.js. When the Web application is hosted on the domain, the Path property is set to a value specific for that domain. An event handler for the ResolveScriptReference event checks the host URL and changes the value for the Path property if it is necessary.

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">
    protected void ScriptManager1_ResolveScriptReference(object sender, ScriptReferenceEventArgs e)
        if (e.Script.Path.Contains("CustomScript"))
            if (HttpContext.Current.Request.Url.Host.ToLower() == "")
                e.Script.Path = "";

<html xmlns="" >
<head runat="server">
    <title>Script Reference Example</title>
    <form id="form1" runat="server">
        <asp:ScriptManager OnResolveScriptReference="ScriptManager1_ResolveScriptReference" ID="ScriptManager1" runat="server">
            <asp:ScriptReference Path="~/scripts/CustomScript.js" />


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5