संपादित करें

इसके माध्यम से साझा किया गया


ScriptManager Class

Definition

Manages ASP.NET Ajax script libraries and script files, partial-page rendering, and client proxy class generation for Web and application services.

public ref class ScriptManager : System::Web::UI::Control, System::Web::UI::IPostBackDataHandler, System::Web::UI::IPostBackEventHandler
[System.Drawing.ToolboxBitmap(typeof(EmbeddedResourceFinder), "System.Web.Resources.ScriptManager.bmp")]
public class ScriptManager : System.Web.UI.Control, System.Web.UI.IPostBackDataHandler, System.Web.UI.IPostBackEventHandler
[<System.Drawing.ToolboxBitmap(typeof(EmbeddedResourceFinder), "System.Web.Resources.ScriptManager.bmp")>]
type ScriptManager = class
    inherit Control
    interface IPostBackDataHandler
    interface IPostBackEventHandler
Public Class ScriptManager
Inherits Control
Implements IPostBackDataHandler, IPostBackEventHandler
Inheritance
ScriptManager
Attributes
Implements

Examples

The following examples show different scenarios for using the ScriptManager control.

Enabling Partial-Page Updates

The following example shows how to use the ScriptManager control to enable partial-page updates. In this example, a Calendar and a DropDownList control are inside an UpdatePanel control. By default, the value of the UpdateMode property is Always, and the value of the ChildrenAsTriggers property is true. Therefore, child controls of the panel cause an asynchronous postback.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    void DropDownSelection_Change(Object sender, EventArgs e)
    {
        Calendar1.DayStyle.BackColor =
            System.Drawing.Color.FromName(ColorList.SelectedItem.Value);
    }

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        SelectedDate.Text = 
            Calendar1.SelectedDate.ToString();
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanel Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" 
                               runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1"
                             runat="server">
                <ContentTemplate>
                    <asp:Calendar ID="Calendar1" 
                                  ShowTitle="True"
                                  OnSelectionChanged="Calendar1_SelectionChanged"
                                  runat="server" />
                    <div>
                        Background:
                        <br />
                        <asp:DropDownList ID="ColorList" 
                                          AutoPostBack="True" 
                                          OnSelectedIndexChanged="DropDownSelection_Change"
                                          runat="server">
                            <asp:ListItem Selected="True" Value="White"> 
                            White </asp:ListItem>
                            <asp:ListItem Value="Silver"> 
                            Silver </asp:ListItem>
                            <asp:ListItem Value="DarkGray"> 
                            Dark Gray </asp:ListItem>
                            <asp:ListItem Value="Khaki"> 
                            Khaki </asp:ListItem>
                            <asp:ListItem Value="DarkKhaki"> D
                            ark Khaki </asp:ListItem>
                        </asp:DropDownList>
                    </div>
                    <br />
                    Selected date:
                    <asp:Label ID="SelectedDate" 
                               runat="server">None.</asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>
            <br />
        </div>
    </form>
</body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Sub DropDownSelection_Change(ByVal Sender As Object, ByVal E As EventArgs)
        Calendar1.DayStyle.BackColor = _
        System.Drawing.Color.FromName(ColorList.SelectedItem.Value)
    End Sub

    Protected Sub Calendar1_SelectionChanged(ByVal Sender As Object, ByVal E As EventArgs)
        SelectedDate.Text = Calendar1.SelectedDate.ToString()
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanel Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" 
                               runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1"
                             runat="server">
                <ContentTemplate>
                    <asp:Calendar ID="Calendar1" 
                                  ShowTitle="True"
                                  OnSelectionChanged="Calendar1_SelectionChanged"
                                  runat="server" />
                    <div>
                        Background:
                        <br />
                        <asp:DropDownList ID="ColorList" 
                                          AutoPostBack="True" 
                                          OnSelectedIndexChanged="DropDownSelection_Change"
                                          runat="server">
                            <asp:ListItem Selected="True" Value="White"> 
                            White </asp:ListItem>
                            <asp:ListItem Value="Silver"> 
                            Silver </asp:ListItem>
                            <asp:ListItem Value="DarkGray"> 
                            Dark Gray </asp:ListItem>
                            <asp:ListItem Value="Khaki"> 
                            Khaki </asp:ListItem>
                            <asp:ListItem Value="DarkKhaki"> D
                            ark Khaki </asp:ListItem>
                        </asp:DropDownList>
                    </div>
                    <br />
                    Selected date:
                    <asp:Label ID="SelectedDate" 
                               runat="server">None.</asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>
            <br />
        </div>
    </form>
</body>
</html>

Handling Partial-Page Update Errors and Registering Script

The following example shows how to provide custom error handling during partial-page updates. By default, when an error occurs during partial-page updates, a JavaScript message box is displayed. This example demonstrates how to use custom error handling by providing a handler for the AsyncPostBackError event, and by setting the AsyncPostBackErrorMessage property in the event handler. You can also set the AllowCustomErrorsRedirect property to specify how the custom errors section of the Web.config file is used when an error occurs during partial-page updates. In this example, the default value of the AllowCustomErrorsRedirect property is used. This means that if the Web.config file contains a customErrors element, that element determines how errors are displayed. For more information, see customErrors Element (ASP.NET Settings Schema).

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            int a = Int32.Parse(TextBox1.Text);
            int b = Int32.Parse(TextBox2.Text);
            int res = a / b;
            Label1.Text = res.ToString();
        }
        catch (Exception ex)
        {
            if (TextBox1.Text.Length > 0 && TextBox2.Text.Length > 0)
            {
                ex.Data["ExtraInfo"] = " You can't divide " +
                    TextBox1.Text + " by " + TextBox2.Text + ".";
            }
            throw ex;
        }
    }

    protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
    {
        if (e.Exception.Data["ExtraInfo"] != null)
        {
            ScriptManager1.AsyncPostBackErrorMessage =
                e.Exception.Message +
                e.Exception.Data["ExtraInfo"].ToString();
        }
        else
        {
            ScriptManager1.AsyncPostBackErrorMessage =
                "An unspecified error occurred.";
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanel Error Handling Example</title>
    <style type="text/css">
    #UpdatePanel1 {
      width: 200px; height: 50px;
      border: solid 1px gray;
    }
    #AlertDiv{
    left: 40%; top: 40%;
    position: absolute; width: 200px;
    padding: 12px; 
    border: #000000 1px solid;
    background-color: white; 
    text-align: left;
    visibility: hidden;
    z-index: 99;
    }
    #AlertButtons{
    position: absolute; right: 5%; bottom: 5%;
    }
    </style>
</head>
<body id="bodytag">
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" 
            OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" runat="server" >
            <Scripts>
            <asp:ScriptReference Path="ErrorHandling.js" />
            </Scripts>
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Width="39px"></asp:TextBox>
                    /
                    <asp:TextBox ID="TextBox2" runat="server" Width="39px"></asp:TextBox>
                    =
                    <asp:Label ID="Label1" runat="server"></asp:Label><br />
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="calculate" />
                </ContentTemplate>
            </asp:UpdatePanel>
            <div id="AlertDiv">
                <div id="AlertMessage">
                </div>
                <br />
                <div id="AlertButtons">
                    <input id="OKButton" type="button" value="OK" runat="server" onclick="ClearErrorState()" />
                </div>
            </div>
        </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Try
            Dim a As Int32
            a = Int32.Parse(TextBox1.Text)
            Dim b As Int32
            b = Int32.Parse(TextBox2.Text)
            Dim res As Int32 = a / b
            Label1.Text = res.ToString()
        Catch ex As Exception
            If (TextBox1.Text.Length > 0 AndAlso TextBox2.Text.Length > 0) Then
                ex.Data("ExtraInfo") = " You can't divide " & _
                  TextBox1.Text & " by " & TextBox2.Text & "."
            End If
            Throw ex
        End Try

    End Sub
    Protected Sub ScriptManager1_AsyncPostBackError(ByVal sender As Object, ByVal e As System.Web.UI.AsyncPostBackErrorEventArgs)
        If (e.Exception.Data("ExtraInfo") <> Nothing) Then
            ScriptManager1.AsyncPostBackErrorMessage = _
               e.Exception.Message & _
               e.Exception.Data("ExtraInfo").ToString()
        Else
            ScriptManager1.AsyncPostBackErrorMessage = _
               "An unspecified error occurred."
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanel Error Handling Example</title>
    <style type="text/css">
    #UpdatePanel1 {
      width: 200px; height: 50px;
      border: solid 1px gray;
    }
    #AlertDiv{
    left: 40%; top: 40%;
    position: absolute; width: 200px;
    padding: 12px; 
    border: #000000 1px solid;
    background-color: white; 
    text-align: left;
    visibility: hidden;
    z-index: 99;
    }
    #AlertButtons{
    position: absolute; right: 5%; bottom: 5%;
    }
    </style>
</head>
<body id="bodytag">
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" 
            OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" runat="server" >
            <Scripts>
            <asp:ScriptReference Path="ErrorHandling.js" />
            </Scripts>
            </asp:ScriptManager>

            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Width="39px"></asp:TextBox>
                    /
                    <asp:TextBox ID="TextBox2" runat="server" Width="39px"></asp:TextBox>
                    =
                    <asp:Label ID="Label1" runat="server"></asp:Label><br />
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="calculate" />
                </ContentTemplate>
            </asp:UpdatePanel>
            <div id="AlertDiv">
                <div id="AlertMessage">
                </div>
                <br />
                <div id="AlertButtons">
                    <input id="OKButton" type="button" value="OK" runat="server" onclick="ClearErrorState()" />
                </div>
            </div>
        </div>
    </form>
</body>
</html>

Globalizing the Date and Time That Are Displayed in the Browser

The following example shows how to set the EnableScriptGlobalization property so that client script can display a culture-specific date and time in the browser. In the example, the Culture attribute of the @ Page directive is set to auto. As a result, the first language that is specified in the current browser settings determines the culture and UI culture for the page. For more information, see How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization.

<%@ Page Language="C#" Culture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Globalization Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true" runat="server">
        </asp:ScriptManager>
        <script type="text/javascript">
        function pageLoad() {
          Sys.UI.DomEvent.addHandler($get("Button1"), "click", formatDate);
        }
        function formatDate() {
          var d = new Date();
          try {
            $get('Label1').innerHTML = d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss");
          }
          catch(e) {
            alert("Error:" + e.message);
          }
        }
        </script>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
        <ContentTemplate>
        <asp:Panel ID="Panel1" runat="server" GroupingText="Update Panel">
        <asp:Button ID="Button1" runat="server" Text="Display Date" />

        <br />

        <asp:Label ID="Label1" runat="server"></asp:Label>
        </asp:Panel>
        </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
<%@ Page Language="VB" Culture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Globalization Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true" runat="server">
        </asp:ScriptManager>
        <script type="text/javascript">
        function pageLoad() {
          Sys.UI.DomEvent.addHandler($get("Button1"), "click", formatDate);
        }
        function formatDate() {
          var d = new Date();
          try {
            $get('Label1').innerHTML = d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss");
          }
          catch(e) {
            alert("Error:" + e.message);
          }
        }
        </script>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
        <ContentTemplate>
        <asp:Panel ID="Panel1" runat="server" GroupingText="Update Panel">
        <asp:Button ID="Button1" runat="server" Text="Display Date" />

        <br />

        <asp:Label ID="Label1" runat="server"></asp:Label>
        </asp:Panel>
        </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>

Remarks

In this topic:

Introduction

The ScriptManager control is central to Ajax functionality in ASP.NET. The control manages all ASP.NET Ajax resources on a page. This includes downloading Microsoft Ajax Library scripts to the browser and coordinating partial-page updates that are enabled by using UpdatePanel controls. In addition, the ScriptManager control enables you to do the following:

  • Register script that is compatible with partial-page updates. In order to manage dependencies between your script and the core library, any script that you register is loaded after the Microsoft Ajax Library script.

  • Specify whether release or debug scripts are sent to the browser.

  • Provide access to Web service methods from script by registering Web services with the ScriptManager control.

  • Provide access to ASP.NET authentication, role, and profile application services from client script by registering these services with the ScriptManager control.

  • Enable culture-specific display of ECMAScript (JavaScript) Date, Number, and String functions in the browser.

  • Access localization resources for embedded script files or for stand-alone script files by using the ResourceUICultures property of the ScriptReference control.

  • Register server controls that implement the IExtenderControl or IScriptControl interfaces with the ScriptManager control so that script required by client components and behaviors is rendered.

Partial-Page Rendering

The ability of an ASP.NET page to support partial-page rendering is controlled by the following factors:

You can override the value of the EnablePartialRendering property at run time during or before the page's Init event. If you try to change this property after the page's Init event has occurred, an InvalidOperationException exception is thrown.

When partial-page rendering is supported, the ScriptManager control renders script to enable asynchronous postbacks and partial-page updates. The regions of the page to be updated are designated by using UpdatePanel controls. The ScriptManager control handles the asynchronous postbacks and refreshes only the regions of the page that have to be updated. For more information about partial-page rendering, see Partial-Page Rendering Overview. For more information about the conditions that cause an update, see UpdatePanel Control Overview.

Using the ScriptManager Control with Master Pages, User Controls, and Other Child Components

A page can contain only one ScriptManager control in its hierarchy. To register services and scripts for nested pages, user controls, or components when the parent page already has a ScriptManager control, use the ScriptManagerProxy control. For more information, see Using the UpdatePanel Control with Master Pages.

Script Management and Registration

The ScriptManager control enables you to register script that is then rendered as part of the page. The ScriptManager control registration methods can be broken into the following three categories:

  • Registration methods that guarantee that script dependencies on the Microsoft Ajax Library are maintained.

  • Registration methods that are not dependent on the Microsoft Ajax Library, but that are compatible with UpdatePanel controls.

  • Registration methods that support working with UpdatePanel controls.

For more information about how to create and use Ajax script in ASP.NET, see Creating Custom Client Script by Using the Microsoft Ajax Library.

Registering Script That Is Dependent on the Microsoft Ajax Library

You can use the following methods to register script files in a way that guarantees that any dependencies on the Microsoft Ajax Library are maintained.

Method Definition
RegisterScriptControl Registers a server control that implements the IScriptControl interface that is used to define a Sys.Component client object. The ScriptManager control renders script that supports the client object.
RegisterExtenderControl Registers a server control that implements the IExtenderControl interface that is used to define a Sys.Component client object. The ScriptManager control renders script that supports the client object.

Registering Partial-Page Update Compatible Scripts

You can use the following methods to register script files that are not dependent on the Microsoft Ajax Library but that are compatible with UpdatePanel controls. These methods correspond to similar methods of the ClientScriptManager control. If you are rendering script for use inside an UpdatePanel control, make sure that you call the methods of the ScriptManager control.

Method Definition
RegisterArrayDeclaration Adds a value to a JavaScript array. If the array does not exist, it is created.
RegisterClientScriptBlock Renders a script element after the page's opening <form> tag. The script is specified as a string parameter.
RegisterClientScriptInclude Renders a script element after the page's opening <form> tag. The script content is specified by setting the src attribute to a URL that points to a script file.
RegisterClientScriptResource Renders a script element after the page's opening <form> tag. The script content is specified with a resource name in an assembly. The src attribute is automatically populated with a URL by a call to an HTTP handler that retrieves the named script from the assembly.
RegisterExpandoAttribute Renders a custom name/value attribute pair (an expando) in the markup for a specified control.
RegisterHiddenField Renders a hidden field.
RegisterOnSubmitStatement Registers a script that is executed in response to the form element's submit event. The onSubmit attribute references the specified script.
RegisterStartupScript Renders a startup script block just before the page's closing </form> tag. The script to render is specified as a string parameter.

When you register methods, you specify a type/key pair for that script. If a script with the same type/key pair is already registered, a new script is not registered. Similarly, if you register a script with a type/resource name pair that already exists, the script element that references the resource is not added again. When you register an expando attribute of a previously registered attribute, an exception is thrown. Duplicate registration of array values is allowed.

When you call the RegisterClientScriptInclude or the RegisterClientScriptResource method, avoid registering script that executes inline functions. Instead, register script that contains function definitions like event handlers or custom class definitions for your application.

Registration Methods for UpdatePanel Controls

You can use the following methods to customize partial-page updates when you use UpdatePanel controls.

Method Definition
RegisterAsyncPostBackControl Registers a control as a trigger for asynchronous postbacks.
RegisterDataItem Sends custom data to controls during partial-page rendering.
RegisterDispose Registers a dispose script for a control that is inside an UpdatePanel control. The script is executed when the UpdatePanel control is updated or deleted. The dispose method is used for client components that are part of the Microsoft Ajax Library and that have to free resources when a component is no longer used.
RegisterPostBackControl Registers a control as a trigger for a full postback. This method is used for controls inside an UpdatePanel control that would otherwise perform asynchronous postbacks.

Web Service References

You can register a Web service to be called from client script by creating a ServiceReference object and adding it to the Services collection of the ScriptManager control. ASP.NET generates a client proxy object for each ServiceReference object in the Services collection. You can programmatically add ServiceReference objects to the Services collection to register Web services at run time.

For more information about how to access Web services in script, see Exposing Web Services to Client Script in ASP.NET AJAX and Calling Web Services from Client Script in ASP.NET AJAX.

Localization

The ScriptManager control generates references in the rendered page that point to the appropriate localized script files, which are either script files embedded in assemblies or stand-alone script files.

When the EnableScriptLocalization property is set to true, the ScriptManager control retrieves localized resources (such as localized strings) for the current culture, if they exist. The ScriptManager control provides the following functionality for using localized resources:

  • Script files that are embedded in an assembly. The ScriptManager control determines which culture-specific or fallback-culture script file to send to the browser. It does this by using the culture-specific NeutralResourcesLanguageAttribute assembly attribute, the resources packaged with the assembly, and the UI culture of the browser (if any).

  • Stand-alone script files. The ScriptManager control defines the list of UI cultures that are supported by using the ResourceUICultures property of the ScriptReference object.

  • In debug mode. The ScriptManager control tries to render a culture-specific script file that contains debug information. For example, if the page is in debug mode and the current culture is set to en-MX, the control renders a script file that has a name such as scriptname.en-MX.debug.js, if the file exists. If the file does not exist, the debug file for the appropriate fallback culture is rendered

For more information about how to localize resources, see Localizing Resources for Component Libraries Overview.

Error Handling

When a page error occurs during asynchronous postbacks, the AsyncPostBackError event is raised. The way in which errors on the server are sent to the client depends on the AllowCustomErrorsRedirect property, the AsyncPostBackErrorMessage property, and the custom errors section of the Web.config file. For more information, see Customizing Error Handling for UpdatePanel Controls.

Declarative Syntax

<asp:ScriptManager  
    AllowCustomErrorsRedirect="True|False"  
    AsyncPostBackErrorMessage="string"  
    AsyncPostBackTimeout="integer"  
    AuthenticationService-Path="uri"  
    EnablePageMethods="True|False"  
    EnablePartialRendering="True|False"  
    EnableScriptGlobalization="True|False"  
    EnableScriptLocalization="True|False"  
    EnableTheming="True|False"  
    EnableViewState="True|False"  
    ID="string"  
    LoadScriptsBeforeUI="True|False"  
    OnAsyncPostBackError="AsyncPostBackError event handler"  
    OnDataBinding="DataBinding event handler"  
    OnDisposed="Disposed event handler"  
    OnInit="Init event handler"  
    OnLoad="Load event handler"  
    OnPreRender="PreRender event handler"  
    OnResolveScriptReference="ResolveScriptReference event handler"  
    OnUnload="Unload event handler"  
    ProfileService-LoadProperties="string"  
    ProfileService-Path="uri"  
    RoleService-LoadRoles="True|False"  
    RoleService-Path="uri"  
    runat="server"  
    ScriptMode="Auto|Inherit|Debug|Release"  
    ScriptPath="string"  
    SkinID="string"  
    SupportsPartialRendering="True|False"  
    Visible="True|False"  
>  
        <AuthenticationService  
            Path="uri"  
        />  
        <ProfileService  
            LoadProperties="string"  
            Path="uri"  
        />  
        <RoleService  
            LoadRoles="True|False"  
            Path="uri"  
        />  
        <Scripts>  
            <asp:ScriptReference  
                Assembly="string"  
                IgnoreScriptPath="True|False"  
                Name="string"  
                NotifyScriptLoaded="True|False"  
                Path="string"  
                ResourceUICultures="string"  
                ScriptMode="Auto|Debug|Inherit|Release"  
            />  
        </Scripts>  
        <Services>  
            <asp:ServiceReference  
                InlineScript="True|False"  
                Path="string"  
            />  
        </Services>  
</asp:ScriptManager>  

Constructors

ScriptManager()

Initializes a new instance of the ScriptManager class.

Properties

Adapter

Gets the browser-specific adapter for the control.

(Inherited from Control)
AjaxFrameworkAssembly

Gets the Ajax framework assembly that components on the page use.

AjaxFrameworkMode

Gets or sets a value that specifies how client scripts of the Microsoft Ajax client library will be included on the client.

AllowCustomErrorsRedirect

Gets or sets a value that determines whether the custom errors section of the Web.config file is used during an error in an asynchronous postback.

AppRelativeTemplateSourceDirectory

Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.

(Inherited from Control)
AsyncPostBackErrorMessage

Gets or sets the error message that is sent to the client when an unhandled server exception occurs during an asynchronous postback.

AsyncPostBackSourceElementID

Gets the unique ID of the control that caused the asynchronous postback.

AsyncPostBackTimeout

Gets or sets a value that indicates the time, in seconds, before asynchronous postbacks time out if no response is received.

AuthenticationService

Gets the AuthenticationServiceManager object that is associated with the current ScriptManager instance.

BindingContainer

Gets the control that contains this control's data binding.

(Inherited from Control)
ChildControlsCreated

Gets a value that indicates whether the server control's child controls have been created.

(Inherited from Control)
ClientID

Gets the control ID for HTML markup that is generated by ASP.NET.

(Inherited from Control)
ClientIDMode

Gets or sets the algorithm that is used to generate the value of the ClientID property.

(Inherited from Control)
ClientIDSeparator

Gets a character value representing the separator character used in the ClientID property.

(Inherited from Control)
ClientNavigateHandler

Gets or sets the name of the method that handles the Sys.Application.navigate event on the client.

CompositeScript

Gets a reference to the composite script that supports the Web page.

Context

Gets the HttpContext object associated with the server control for the current Web request.

(Inherited from Control)
Controls

Gets a ControlCollection object that represents the child controls for a specified server control in the UI hierarchy.

(Inherited from Control)
DataItemContainer

Gets a reference to the naming container if the naming container implements IDataItemContainer.

(Inherited from Control)
DataKeysContainer

Gets a reference to the naming container if the naming container implements IDataKeysControl.

(Inherited from Control)
DesignMode

Gets a value indicating whether a control is being used on a design surface.

(Inherited from Control)
EmptyPageUrl

Gets or sets a URL to a blank Web page.

EnableCdn

Determines whether the current page loads client script references from CDN (Content Delivery Network) paths.

EnableCdnFallback

Enables local copy of a script to load in the event that the CDN (Content Delivery Network) is unavailable.

EnableHistory

Gets or sets a value that indicates whether the Web page supports history point management.

EnablePageMethods

Gets or sets a value that indicates whether public static page methods in an ASP.NET page can be called from client script.

EnablePartialRendering

Gets or sets a value that enables partial rendering of a page, which in turn enables you to update regions of the page individually by using UpdatePanel controls.

EnableScriptGlobalization

Gets or sets a value that indicates whether the ScriptManager control renders script that supports parsing and formatting of culture-specific information.

EnableScriptLocalization

Gets or sets a value that indicates whether the ScriptManager control renders localized versions of script files.

EnableSecureHistoryState

Gets or sets a value that indicates whether to encrypt the history state string.

EnableTheming

Gets or sets a value indicating whether themes apply to this control.

(Inherited from Control)
EnableViewState

Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

(Inherited from Control)
Events

Gets a list of event handler delegates for the control. This property is read-only.

(Inherited from Control)
HasChildViewState

Gets a value indicating whether the current server control's child controls have any saved view-state settings.

(Inherited from Control)
ID

Gets or sets the programmatic identifier assigned to the server control.

(Inherited from Control)
IdSeparator

Gets the character used to separate control identifiers.

(Inherited from Control)
IsChildControlStateCleared

Gets a value indicating whether controls contained within this control have control state.

(Inherited from Control)
IsDebuggingEnabled

Gets a value that indicates whether the debug versions of client script libraries will be rendered.

IsInAsyncPostBack

Gets a value that indicates whether the current postback is being executed in partial-rendering mode.

IsNavigating

Gets a value that indicates whether a Navigate event is currently being handled.

IsTrackingViewState

Gets a value that indicates whether the server control is saving changes to its view state.

(Inherited from Control)
IsViewStateEnabled

Gets a value indicating whether view state is enabled for this control.

(Inherited from Control)
LoadScriptsBeforeUI

Gets or sets a value that indicates whether scripts are loaded before or after markup for the page UI is loaded.

LoadViewStateByID

Gets a value indicating whether the control participates in loading its view state by ID instead of index.

(Inherited from Control)
NamingContainer

Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value.

(Inherited from Control)
Page

Gets a reference to the Page instance that contains the server control.

(Inherited from Control)
Parent

Gets a reference to the server control's parent control in the page control hierarchy.

(Inherited from Control)
ProfileService

Gets the ProfileServiceManager object that is associated with the current ScriptManager instance.

RenderingCompatibility

Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.

(Inherited from Control)
RoleService

Gets the RoleServiceManager object that is associated with the current ScriptManager instance.

ScriptMode

Gets or sets a value that specifies whether debug or release versions of client script libraries are rendered.

ScriptPath
Obsolete.

Gets or sets the root path of the location that is used to build the paths to ASP.NET Ajax and custom script files.

ScriptResourceMapping

Gets a ScriptResourceMapping object.

Scripts

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

Services

Gets a ServiceReferenceCollection object that contains a ServiceReference object for each Web service that ASP.NET exposes on the client for Ajax functionality.

Site

Gets information about the container that hosts the current control when rendered on a design surface.

(Inherited from Control)
SkinID

Gets or sets the skin to apply to the control.

(Inherited from Control)
SupportsPartialRendering

Gets a value that indicates whether the client supports partial-page rendering.

TemplateControl

Gets or sets a reference to the template that contains this control.

(Inherited from Control)
TemplateSourceDirectory

Gets the virtual directory of the Page or UserControl that contains the current server control.

(Inherited from Control)
UniqueID

Gets the unique, hierarchically qualified identifier for the server control.

(Inherited from Control)
ValidateRequestMode

Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values.

(Inherited from Control)
ViewState

Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

(Inherited from Control)
ViewStateIgnoresCase

Gets a value that indicates whether the StateBag object is case-insensitive.

(Inherited from Control)
ViewStateMode

Gets or sets the view-state mode of this control.

(Inherited from Control)
Visible

Overrides the Visible property that is inherited from the base Control class to prevent setting this value.

Methods

AddedControl(Control, Int32)

Called after a child control is added to the Controls collection of the Control object.

(Inherited from Control)
AddHistoryPoint(NameValueCollection, String)

Creates a history point and adds it to the browser's history stack, using the specified state data collection and state title.

AddHistoryPoint(String, String, String)

Creates a history point and adds it to the browser's history stack, using the specified state key, state value, and state title.

AddHistoryPoint(String, String)

Creates a history point and adds it to the browser's history stack, using the specified state key and state value.

AddParsedSubObject(Object)

Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object.

(Inherited from Control)
ApplyStyleSheetSkin(Page)

Applies the style properties defined in the page style sheet to the control.

(Inherited from Control)
BeginRenderTracing(TextWriter, Object)

Begins design-time tracing of rendering data.

(Inherited from Control)
BuildProfileTree(String, Boolean)

Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page.

(Inherited from Control)
ClearCachedClientID()

Sets the cached ClientID value to null.

(Inherited from Control)
ClearChildControlState()

Deletes the control-state information for the server control's child controls.

(Inherited from Control)
ClearChildState()

Deletes the view-state and control-state information for all the server control's child controls.

(Inherited from Control)
ClearChildViewState()

Deletes the view-state information for all the server control's child controls.

(Inherited from Control)
ClearEffectiveClientIDMode()

Sets the ClientIDMode property of the current control instance and of any child controls to Inherit.

(Inherited from Control)
CreateChildControls()

Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.

(Inherited from Control)
CreateControlCollection()

Creates a new ControlCollection object to hold the child controls (both literal and server) of the server control.

(Inherited from Control)
DataBind()

Binds a data source to the invoked server control and all its child controls.

(Inherited from Control)
DataBind(Boolean)

Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event.

(Inherited from Control)
DataBindChildren()

Binds a data source to the server control's child controls.

(Inherited from Control)
Dispose()

Enables a server control to perform final clean up before it is released from memory.

(Inherited from Control)
EndRenderTracing(TextWriter, Object)

Ends design-time tracing of rendering data.

(Inherited from Control)
EnsureChildControls()

Determines whether the server control contains child controls. If it does not, it creates child controls.

(Inherited from Control)
EnsureID()

Creates an identifier for controls that do not have an identifier assigned.

(Inherited from Control)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindControl(String, Int32)

Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. You should not override this version of the FindControl method.

(Inherited from Control)
FindControl(String)

Searches the current naming container for a server control with the specified id parameter.

(Inherited from Control)
Focus()

Sets input focus to a control.

(Inherited from Control)
GetCurrent(Page)

Gets the ScriptManager instance for a given Page object.

GetDesignModeState()

Gets design-time data for a control.

(Inherited from Control)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRegisteredArrayDeclarations()

Retrieves a read-only collection of ECMAScript (JavaScript) array declarations that were previously registered with the Page object.

GetRegisteredClientScriptBlocks()

Retrieves a read-only collection of client script blocks that were previously registered with the ScriptManager control.

GetRegisteredDisposeScripts()

Retrieves a read-only collection of dispose scripts that were previously registered with the Page object.

GetRegisteredExpandoAttributes()

Retrieves a read-only collection of custom (expando) attributes that were previously registered with the Page object.

GetRegisteredHiddenFields()

Retrieves a read-only collection of hidden fields that were previously registered with the Page object.

GetRegisteredOnSubmitStatements()

Retrieves a read-only collection of onsubmit statements that were previously registered with the Page object.

GetRegisteredStartupScripts()

Retrieves a read-only collection of startup scripts that were previously registered with the Page object.

GetRouteUrl(Object)

Gets the URL that corresponds to a set of route parameters.

(Inherited from Control)
GetRouteUrl(RouteValueDictionary)

Gets the URL that corresponds to a set of route parameters.

(Inherited from Control)
GetRouteUrl(String, Object)

Gets the URL that corresponds to a set of route parameters and a route name.

(Inherited from Control)
GetRouteUrl(String, RouteValueDictionary)

Gets the URL that corresponds to a set of route parameters and a route name.

(Inherited from Control)
GetStateString()

Retrieves a string that contains key/value pairs that represent the state of the Web page.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetUniqueIDRelativeTo(Control)

Returns the prefixed portion of the UniqueID property of the specified control.

(Inherited from Control)
HasControls()

Determines if the server control contains any child controls.

(Inherited from Control)
HasEvents()

Returns a value indicating whether events are registered for the control or any child controls.

(Inherited from Control)
IsLiteralContent()

Determines if the server control holds only literal content.

(Inherited from Control)
LoadControlState(Object)

Restores control-state information from a previous page request that was saved by the SaveControlState() method.

(Inherited from Control)
LoadPostData(String, NameValueCollection)

Reads form data that is posted from the browser to the server, and determines the source of the asynchronous postback.

LoadViewState(Object)

Restores view-state information from a previous page request that was saved by the SaveViewState() method.

(Inherited from Control)
MapPathSecure(String)

Retrieves the physical path that a virtual path, either absolute or relative, maps to.

(Inherited from Control)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnAsyncPostBackError(AsyncPostBackErrorEventArgs)

Raises the AsyncPostBackError event.

OnBubbleEvent(Object, EventArgs)

Determines whether the event for the server control is passed up the page's UI server control hierarchy.

(Inherited from Control)
OnDataBinding(EventArgs)

Raises the DataBinding event.

(Inherited from Control)
OnInit(EventArgs)

Raises the Init event and makes sure that only one ScriptManager control exists on the page.

OnLoad(EventArgs)

Raises the Load event.

(Inherited from Control)
OnPreRender(EventArgs)

Raises the PreRender event, and registers script files and services for partial-page updates.

OnResolveCompositeScriptReference(CompositeScriptReferenceEventArgs)

Raises the ResolveCompositeScriptReference event.

OnResolveScriptReference(ScriptReferenceEventArgs)

Raises the ResolveScriptReference event for each script reference that is managed by the ScriptManager control.

OnUnload(EventArgs)

Raises the Unload event.

(Inherited from Control)
OpenFile(String)

Gets a Stream used to read a file.

(Inherited from Control)
RaiseBubbleEvent(Object, EventArgs)

Assigns any sources of the event and its information to the control's parent.

(Inherited from Control)
RaisePostBackEvent(String)

Processes a postback event raised by the ScriptManager control and loads the history state of the Web page.

RaisePostDataChangedEvent()

Raises events for the ScriptManager control when it posts back to the server.

RegisterArrayDeclaration(Control, String, String)

Registers an ECMAScript (JavaScript) array declaration with the ScriptManager control for use with a control that is inside an UpdatePanel control, and adds the array to the page.

RegisterArrayDeclaration(Page, String, String)

Registers an ECMAScript (JavaScript) array declaration with the ScriptManager control for use with a control that is inside an UpdatePanel control, and adds the array to the page.

RegisterAsyncPostBackControl(Control)

Registers a control as a trigger for asynchronous postbacks.

RegisterClientScriptBlock(Control, Type, String, String, Boolean)

Registers a client script block with the ScriptManager control for use with a control that is inside an UpdatePanel control, and then adds the script block to the page.

RegisterClientScriptBlock(Page, Type, String, String, Boolean)

Registers a client script block with the ScriptManager control for use with a control that is inside an UpdatePanel control, and then adds the script block to the page.

RegisterClientScriptInclude(Control, Type, String, String)

Registers a client script file with the ScriptManager control for use with a control that is inside an UpdatePanel control, and then adds a script file reference to the page.

RegisterClientScriptInclude(Page, Type, String, String)

Registers client script with the ScriptManager control every time that an asynchronous postback occurs, and then adds a script file reference to the page.

RegisterClientScriptResource(Control, Type, String)

Registers the client script that is embedded in an assembly with the ScriptManager control for use with a control that is participating in partial-page rendering.

RegisterClientScriptResource(Page, Type, String)

Registers a client script file that is embedded in an assembly with the ScriptManager control every time that a postback occurs.

RegisterDataItem(Control, String, Boolean)

Sends custom data to a control during partial-page rendering, and indicates whether the data is in JavaScript Object Notation (JSON) format.

RegisterDataItem(Control, String)

Sends custom data to a control during partial-page rendering.

RegisterDispose(Control, String)

Registers a dispose script for a control that is inside an UpdatePanel control. The script is executed when the UpdatePanel control is updated or deleted.

RegisterExpandoAttribute(Control, String, String, String, Boolean)

Registers a name/value pair with the ScriptManager control as a custom (expando) attribute of a specified control.

RegisterExtenderControl<TExtenderControl>(TExtenderControl, Control)

Registers an extender control with the current ScriptManager instance.

RegisterHiddenField(Control, String, String)

Registers a hidden field with the ScriptManager control for a control that is inside an UpdatePanel control.

RegisterHiddenField(Page, String, String)

Registers a hidden field with the ScriptManager control during every asynchronous postback.

RegisterNamedClientScriptResource(Control, String)

Registers client script by resource name that is embedded in an assembly with the ScriptManager control for use with a control that is participating in partial-page rendering.

RegisterNamedClientScriptResource(Page, String)

Registers client script by resource name that is embedded in an assembly with the ScriptManager control for use with a control that is participating in partial-page rendering.

RegisterOnSubmitStatement(Control, Type, String, String)

Registers ECMAScript (JavaScript) code with the ScriptManager control for a control that is used with an UpdatePanel control that is executed when the form is submitted.

RegisterOnSubmitStatement(Page, Type, String, String)

Registers ECMAScript (JavaScript) code with the ScriptManager control for a control that is used with an UpdatePanel control that is executed when the form is submitted.

RegisterPostBackControl(Control)

Registers a control as a trigger for a postback. This method is used to configure postback controls inside an UpdatePanel control that would otherwise perform asynchronous postbacks.

RegisterScriptControl<TScriptControl>(TScriptControl)

Registers a script control with the current ScriptManager instance.

RegisterScriptDescriptors(IExtenderControl)

Calls back to an ExtenderControl class to return instance scripts that must be rendered to support the client object that represents a client control, component, or behavior.

RegisterScriptDescriptors(IScriptControl)

Calls a ScriptControl class to return instance scripts that must be rendered to support the client object that represents a client control, component, or behavior.

RegisterStartupScript(Control, Type, String, String, Boolean)

Registers a startup script block for a control that is inside an UpdatePanel by using the ScriptManager control, and adds the script block to the page.

RegisterStartupScript(Page, Type, String, String, Boolean)

Registers a startup script block for every asynchronous postback with the ScriptManager control and adds the script block to the page.

RemovedControl(Control)

Called after a child control is removed from the Controls collection of the Control object.

(Inherited from Control)
Render(HtmlTextWriter)

Renders the ScriptManager control's content to the browser by using the specified HtmlTextWriter object.

RenderChildren(HtmlTextWriter)

Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(Inherited from Control)
RenderControl(HtmlTextWriter, ControlAdapter)

Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.

(Inherited from Control)
RenderControl(HtmlTextWriter)

Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

(Inherited from Control)
ResolveAdapter()

Gets the control adapter responsible for rendering the specified control.

(Inherited from Control)
ResolveClientUrl(String)

Gets a URL that can be used by the browser.

(Inherited from Control)
ResolveUrl(String)

Converts a URL into one that is usable on the requesting client.

(Inherited from Control)
SaveControlState()

Saves any server control state changes that have occurred since the time the page was posted back to the server.

(Inherited from Control)
SaveViewState()

Saves any server control view-state changes that have occurred since the time the page was posted back to the server.

(Inherited from Control)
SetDesignModeState(IDictionary)

Sets design-time data for a control.

(Inherited from Control)
SetFocus(Control)

Sets the browser focus to the specified control.

SetFocus(String)

Sets the browser focus to the control specified by ID.

SetRenderMethodDelegate(RenderMethod)

Assigns an event handler delegate to render the server control and its content into its parent control.

(Inherited from Control)
SetTraceData(Object, Object, Object)

Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value.

(Inherited from Control)
SetTraceData(Object, Object)

Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.

(Inherited from Control)
ToString()

Returns a string that represents the current object.

(Inherited from Object)
TrackViewState()

Causes tracking of view-state changes to the server control so they can be stored in the server control's StateBag object. This object is accessible through the ViewState property.

(Inherited from Control)

Events

AsyncPostBackError

Occurs when there is a page error during an asynchronous postback.

DataBinding

Occurs when the server control binds to a data source.

(Inherited from Control)
Disposed

Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

(Inherited from Control)
Init

Occurs when the server control is initialized, which is the first step in its lifecycle.

(Inherited from Control)
Load

Occurs when the server control is loaded into the Page object.

(Inherited from Control)
Navigate

Occurs when the user clicks the browser's Back or Forward button.

PreRender

Occurs after the Control object is loaded but prior to rendering.

(Inherited from Control)
ResolveCompositeScriptReference

Occurs when a composite script is registered with the ScriptManager control.

ResolveScriptReference

Occurs when a member of the Scripts collection is registered with the ScriptManager control.

Unload

Occurs when the server control is unloaded from memory.

(Inherited from Control)

Explicit Interface Implementations

IControlBuilderAccessor.ControlBuilder

For a description of this member, see ControlBuilder.

(Inherited from Control)
IControlDesignerAccessor.GetDesignModeState()

For a description of this member, see GetDesignModeState().

(Inherited from Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

For a description of this member, see SetDesignModeState(IDictionary).

(Inherited from Control)
IControlDesignerAccessor.SetOwnerControl(Control)

For a description of this member, see SetOwnerControl(Control).

(Inherited from Control)
IControlDesignerAccessor.UserData

For a description of this member, see UserData.

(Inherited from Control)
IDataBindingsAccessor.DataBindings

For a description of this member, see DataBindings.

(Inherited from Control)
IDataBindingsAccessor.HasDataBindings

For a description of this member, see HasDataBindings.

(Inherited from Control)
IExpressionsAccessor.Expressions

For a description of this member, see Expressions.

(Inherited from Control)
IExpressionsAccessor.HasExpressions

For a description of this member, see HasExpressions.

(Inherited from Control)
IParserAccessor.AddParsedSubObject(Object)

For a description of this member, see AddParsedSubObject(Object).

(Inherited from Control)
IPostBackDataHandler.LoadPostData(String, NameValueCollection)

For a description of this member, see LoadPostData(String, NameValueCollection).

IPostBackDataHandler.RaisePostDataChangedEvent()

For a description of this member, see RaisePostDataChangedEvent().

IPostBackEventHandler.RaisePostBackEvent(String)

Enables the ScriptManager control to process a postback event and load the history state of the Web page.

Extension Methods

FindDataSourceControl(Control)

Returns the data source that is associated with the data control for the specified control.

FindFieldTemplate(Control, String)

Returns the field template for the specified column in the specified control's naming container.

FindMetaTable(Control)

Returns the metatable object for the containing data control.

Applies to

See also