Export (0) Print
Expand All
Expand Minimize

ScriptMode Enumeration

Specifies whether ScriptManager and ScriptReference objects refer to the debug or release version of client scripts.

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

public enum ScriptMode

Member nameDescription
AutoIn the ScriptManager control, the version of client scripts to use is determined at run time based on the application-level <compilation> element of the Web.config file, unless it is overridden in an instance of the ScriptReference control. In the ScriptReference control, when applied to a standalone script file, Auto is equivalent to Release. When applied to a script reference in an assembly, Auto is equivalent to Inherit.
DebugIn the ScriptManager control, the debug version of the client script is used on the Web page unless overridden in an instance of the ScriptReference control. In the ScriptReference control, the debug version of the client script is used on the Web page.
InheritIn the ScriptManager control, Inherit is equivalent to Auto. In the ScriptReference control, the ScriptMode value from ScriptManager determines which version of the client script to use.
ReleaseIn the ScriptManager control, the release version of the client script is used on the Web page unless overridden by setting the ScriptMode property of a ScriptReference instance to Debug. In the ScriptReference control, the release version of the client script is used on the Web page.

The ScriptMode enumerator provides values for setting which version of client script to use on a Web page. The enumerator values can be applied to either the ScriptMode property of the ScriptManager object, or to the ScriptMode property of the ScriptReference object. The ScriptManager object sets the version for all scripts on the page unless it is overridden by a ScriptReference object. The ScriptReference object sets the version for a particular script.

The Auto value produces different results depending on whether it refers to a standalone script file or to a script file that is embedded as a resource in an assembly. A standalone script file is defined with the Path property. An assembly reference must be accessed through the Name and Assembly properties. The results for the Auto value are as follows:

  • When it is applied to a standalone script file where the Path property is specified, the Auto value is equivalent to Release.

  • When it is applied to a script reference in an assembly, Auto is equivalent to Inherit. When only Name is specified, it is used to reference the script. When Name and the Path property are both specified, the Path property is used instead of Name, but the Auto value is still equivalent to Inherit.

An error is thrown if the requested version of the script does not exist. For instance, an error is thrown if a reference is made to a standalone script file that is named CustomScript.js and ScriptMode is set to Debug, but CustomScript.debug.js does not exist on the site. References to scripts in an assembly return the release version if the debug version does not exist.

NoteNote

When the retail attribute of the deployment element of the Machine.config file is set to true, the release versions of client scripts are used throughout the Web site. The ScriptMode values in the ScriptManager and ScriptReference properties are ignored.

The following example shows a page where the script versions are declaratively set to Release in the ScriptManager control, but one script named CustomClient.js is declaratively set to Debug in the ScriptReference control.

<asp:ScriptManager ID="SM" runat="server" ScriptMode="Release">
    <Scripts>
        <asp:ScriptReference Path="CustomClient.js" ScriptMode="Debug" />
    </Scripts>
</asp:ScriptManager>

.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