Επεξεργασία

Κοινή χρήση μέσω


ScriptMode Enum

Definition

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

public enum class ScriptMode
public enum ScriptMode
type ScriptMode = 
Public Enum ScriptMode
Inheritance
ScriptMode

Fields

Name Value Description
Auto 0

In 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.

Inherit 1

In 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.

Debug 2

In 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.

Release 3

In 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.

Examples

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 Name control.

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

Remarks

The ScriptMode enumeration provides values for setting the version of client script to use on a Web page. The enumeration values can be applied to either the ScriptManager.ScriptMode property or to the ScriptReference.ScriptMode property. 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 ScriptMode.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 ScriptReference.Path property. An assembly reference must be accessed through the Name and Assembly properties. The results for the ScriptMode.Auto value are as follows:

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 the ScriptManager.ScriptMode property is set to ScriptMode.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.

Note

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.ScriptMode and ScriptReference.ScriptMode properties are ignored.

Applies to