ScriptManager Class
 

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

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

Inheritance Hierarchy
SystemObject
   System.Web.UIControl
    System.Web.UIScriptManager

Syntax
public class ScriptManager : Control, IPostBackDataHandler, IPostBackEventHandler
public ref class ScriptManager : Control, IPostBackDataHandler, 
	IPostBackEventHandler
type ScriptManager = 
    class
        inherit Control
        interface IPostBackDataHandler
        interface IPostBackEventHandler
    end
Public Class ScriptManager
	Inherits Control
	Implements IPostBackDataHandler, IPostBackEventHandler
Constructors
NameDescription
System_CAPS_pubmethod ScriptManager

Initializes a new instance of the ScriptManager class.

Properties
NameDescription
System_CAPS_protproperty

Gets the browser-specific adapter for the control.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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.

System_CAPS_pubproperty

Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

This API supports the product infrastructure and is not intended to be used directly from your code. Gets the control that contains this control's data binding.(Inherited from Control.)

System_CAPS_protproperty

Gets a value that indicates whether the server control's child controls have been created.(Inherited from Control.)

System_CAPS_pubproperty

Gets the control ID for HTML markup that is generated by ASP.NET.(Inherited from Control.)

System_CAPS_pubproperty

Gets or sets the algorithm that is used to generate the value of the property.(Inherited from Control.)

System_CAPS_protproperty

Gets a character value representing the separator character used in the property.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_protproperty

Gets the HttpContext object associated with the server control for the current Web request.(Inherited from Control.)

System_CAPS_pubproperty

Gets a ControlCollection object that represents the child controls for a specified server control in the UI hierarchy.(Inherited from Control.)

System_CAPS_pubproperty

Gets a reference to the naming container if the naming container implements IDataItemContainer.(Inherited from Control.)

System_CAPS_pubproperty

Gets a reference to the naming container if the naming container implements IDataKeysControl.(Inherited from Control.)

System_CAPS_protproperty

Gets a value indicating whether a control is being used on a design surface.(Inherited from Control.)

System_CAPS_pubproperty

Gets or sets a URL to a blank Web page.

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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.

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

Gets or sets a value indicating whether themes apply to this control.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_protproperty

Gets a list of event handler delegates for the control. This property is read-only.(Inherited from Control.)

System_CAPS_protproperty

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

System_CAPS_pubproperty

Gets or sets the programmatic identifier assigned to the server control.(Inherited from Control.)

System_CAPS_protproperty

This API supports the product infrastructure and is not intended to be used directly from your code. Gets the character used to separate control identifiers.(Inherited from Control.)

System_CAPS_protproperty

Gets a value indicating whether controls contained within this control have control state.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_protproperty

Gets a value that indicates whether the server control is saving changes to its view state.(Inherited from Control.)

System_CAPS_protproperty

Gets a value indicating whether view state is enabled for this control.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_protproperty

Gets a value indicating whether the control participates in loading its view state by instead of index. (Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

Gets a reference to the Page instance that contains the server control.(Inherited from Control.)

System_CAPS_pubproperty

Gets a reference to the server control's parent control in the page control hierarchy.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

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.

System_CAPS_pubproperty System_CAPS_static
System_CAPS_pubproperty

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

System_CAPS_pubproperty

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

System_CAPS_pubproperty

Gets information about the container that hosts the current control when rendered on a design surface.(Inherited from Control.)

System_CAPS_pubproperty

Gets or sets the skin to apply to the control.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_pubproperty

Gets or sets a reference to the template that contains this control. (Inherited from Control.)

System_CAPS_pubproperty

Gets the virtual directory of the Page or UserControl that contains the current server control.(Inherited from Control.)

System_CAPS_pubproperty

Gets the unique, hierarchically qualified identifier for the server control.(Inherited from Control.)

System_CAPS_pubproperty

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

System_CAPS_protproperty

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

System_CAPS_protproperty

Gets a value that indicates whether the StateBag object is case-insensitive.(Inherited from Control.)

System_CAPS_pubproperty

Gets or sets the view-state mode of this control.(Inherited from Control.)

System_CAPS_pubproperty

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

Methods
NameDescription
System_CAPS_protmethod AddedControl

Called after a child control is added to the collection of the Control object.(Inherited from Control.)

System_CAPS_pubmethod AddHistoryPoint

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

System_CAPS_pubmethod AddHistoryPoint

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

System_CAPS_pubmethod AddHistoryPoint

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

System_CAPS_protmethod AddParsedSubObject

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

System_CAPS_pubmethod ApplyStyleSheetSkin

Applies the style properties defined in the page style sheet to the control.(Inherited from Control.)

System_CAPS_protmethod BeginRenderTracing

Begins design-time tracing of rendering data.(Inherited from Control.)

System_CAPS_protmethod BuildProfileTree

This API supports the product infrastructure and is not intended to be used directly from your code. Gathers information about the server control and delivers it to the property to be displayed when tracing is enabled for the page.(Inherited from Control.)

System_CAPS_protmethod ClearCachedClientID

This API supports the product infrastructure and is not intended to be used directly from your code. Sets the cached value to null.(Inherited from Control.)

System_CAPS_protmethod ClearChildControlState

Deletes the control-state information for the server control's child controls. (Inherited from Control.)

System_CAPS_protmethod ClearChildState

Deletes the view-state and control-state information for all the server control's child controls.(Inherited from Control.)

System_CAPS_protmethod ClearChildViewState

Deletes the view-state information for all the server control's child controls.(Inherited from Control.)

System_CAPS_protmethod ClearEffectiveClientIDMode

This API supports the product infrastructure and is not intended to be used directly from your code. Sets the property of the current control instance and of any child controls to Inherit.(Inherited from Control.)

System_CAPS_protmethod 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.)

System_CAPS_protmethod CreateControlCollection

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

System_CAPS_pubmethod DataBind

Binds a data source to the invoked server control and all its child controls.(Inherited from Control.)

System_CAPS_protmethod DataBind

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

System_CAPS_protmethod DataBindChildren

Binds a data source to the server control's child controls.(Inherited from Control.)

System_CAPS_pubmethod Dispose

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

System_CAPS_protmethod EndRenderTracing

Ends design-time tracing of rendering data.(Inherited from Control.)

System_CAPS_protmethod EnsureChildControls

Determines whether the server control contains child controls. If it does not, it creates child controls.(Inherited from Control.)

System_CAPS_protmethod EnsureID

Creates an identifier for controls that do not have an identifier assigned.(Inherited from Control.)

System_CAPS_pubmethod Equals

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethod Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethod FindControl

Searches the current naming container for a server control with the specified id parameter.(Inherited from Control.)

System_CAPS_protmethod FindControl

This API supports the product infrastructure and is not intended to be used directly from your code. 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.)

System_CAPS_pubmethod Focus

Sets input focus to a control.(Inherited from Control.)

System_CAPS_pubmethod System_CAPS_static GetCurrent

Gets the ScriptManager instance for a given Page object.

System_CAPS_protmethod GetDesignModeState

This API supports the product infrastructure and is not intended to be used directly from your code. Gets design-time data for a control.(Inherited from Control.)

System_CAPS_pubmethod GetHashCode

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethod GetRegisteredArrayDeclarations

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

System_CAPS_pubmethod GetRegisteredClientScriptBlocks

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

System_CAPS_pubmethod GetRegisteredDisposeScripts

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

System_CAPS_pubmethod GetRegisteredExpandoAttributes

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

System_CAPS_pubmethod GetRegisteredHiddenFields

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

System_CAPS_pubmethod GetRegisteredOnSubmitStatements

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

System_CAPS_pubmethod GetRegisteredStartupScripts

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

System_CAPS_pubmethod GetRouteUrl

Gets the URL that corresponds to a set of route parameters.(Inherited from Control.)

System_CAPS_pubmethod GetRouteUrl

Gets the URL that corresponds to a set of route parameters.(Inherited from Control.)

System_CAPS_pubmethod GetRouteUrl

Gets the URL that corresponds to a set of route parameters and a route name.(Inherited from Control.)

System_CAPS_pubmethod GetRouteUrl

Gets the URL that corresponds to a set of route parameters and a route name.(Inherited from Control.)

System_CAPS_pubmethod GetStateString

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

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod GetUniqueIDRelativeTo

Returns the prefixed portion of the property of the specified control.(Inherited from Control.)

System_CAPS_pubmethod HasControls

Determines if the server control contains any child controls.(Inherited from Control.)

System_CAPS_protmethod HasEvents

Returns a value indicating whether events are registered for the control or any child controls.(Inherited from Control.)

System_CAPS_protmethod IsLiteralContent

This API supports the product infrastructure and is not intended to be used directly from your code. Determines if the server control holds only literal content.(Inherited from Control.)

System_CAPS_protmethod LoadControlState

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

System_CAPS_protmethod LoadPostData

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

System_CAPS_protmethod LoadViewState

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

System_CAPS_protmethod MapPathSecure

Retrieves the physical path that a virtual path, either absolute or relative, maps to.(Inherited from Control.)

System_CAPS_protmethod MemberwiseClone

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethod OnAsyncPostBackError

Raises the AsyncPostBackError event.

System_CAPS_protmethod OnBubbleEvent

Determines whether the event for the server control is passed up the page's UI server control hierarchy.(Inherited from Control.)

System_CAPS_protmethod OnDataBinding

Raises the DataBinding event.(Inherited from Control.)

System_CAPS_protmethod OnInit

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

System_CAPS_protmethod OnLoad

Raises the Load event.(Inherited from Control.)

System_CAPS_protmethod OnPreRender

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

System_CAPS_protmethod OnResolveCompositeScriptReference
System_CAPS_protmethod OnResolveScriptReference

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

System_CAPS_protmethod OnUnload

Raises the Unload event.(Inherited from Control.)

System_CAPS_protmethod OpenFile

Gets a Stream used to read a file.(Inherited from Control.)

System_CAPS_protmethod RaiseBubbleEvent

Assigns any sources of the event and its information to the control's parent.(Inherited from Control.)

System_CAPS_protmethod RaisePostBackEvent

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

System_CAPS_protmethod RaisePostDataChangedEvent

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

System_CAPS_pubmethod System_CAPS_static RegisterArrayDeclaration

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.

System_CAPS_pubmethod System_CAPS_static RegisterArrayDeclaration

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.

System_CAPS_pubmethod RegisterAsyncPostBackControl

Registers a control as a trigger for asynchronous postbacks.

System_CAPS_pubmethod System_CAPS_static RegisterClientScriptBlock

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.

System_CAPS_pubmethod System_CAPS_static RegisterClientScriptBlock

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.

System_CAPS_pubmethod System_CAPS_static RegisterClientScriptInclude

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.

System_CAPS_pubmethod System_CAPS_static RegisterClientScriptInclude

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

System_CAPS_pubmethod System_CAPS_static RegisterClientScriptResource

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.

System_CAPS_pubmethod System_CAPS_static RegisterClientScriptResource

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

System_CAPS_pubmethod RegisterDataItem

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

System_CAPS_pubmethod RegisterDataItem

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

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

System_CAPS_pubmethod System_CAPS_static RegisterExpandoAttribute

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

System_CAPS_pubmethod RegisterExtenderControl

Registers an extender control with the current ScriptManager instance.

System_CAPS_pubmethod System_CAPS_static RegisterHiddenField

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

System_CAPS_pubmethod System_CAPS_static RegisterHiddenField

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

System_CAPS_pubmethod System_CAPS_static RegisterNamedClientScriptResource

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.

System_CAPS_pubmethod System_CAPS_static RegisterNamedClientScriptResource

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.

System_CAPS_pubmethod System_CAPS_static RegisterOnSubmitStatement

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.

System_CAPS_pubmethod System_CAPS_static RegisterOnSubmitStatement

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.

System_CAPS_pubmethod RegisterPostBackControl

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.

System_CAPS_pubmethod RegisterScriptControl

Registers a script control with the current ScriptManager instance.

System_CAPS_pubmethod RegisterScriptDescriptors

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

System_CAPS_pubmethod RegisterScriptDescriptors

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

System_CAPS_pubmethod System_CAPS_static RegisterStartupScript

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.

System_CAPS_pubmethod System_CAPS_static RegisterStartupScript

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

System_CAPS_protmethod RemovedControl

Called after a child control is removed from the collection of the Control object.(Inherited from Control.)

System_CAPS_protmethod Render

Renders the ScriptManager control's content to the browser by using the specified HtmlTextWriter object.(Overrides ControlRender.)

System_CAPS_protmethod RenderChildren

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

System_CAPS_pubmethod RenderControl

Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.(Inherited from Control.)

System_CAPS_protmethod RenderControl

Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.(Inherited from Control.)

System_CAPS_protmethod ResolveAdapter

Gets the control adapter responsible for rendering the specified control.(Inherited from Control.)

System_CAPS_pubmethod ResolveClientUrl

Gets a URL that can be used by the browser.(Inherited from Control.)

System_CAPS_pubmethod ResolveUrl

Converts a URL into one that is usable on the requesting client.(Inherited from Control.)

System_CAPS_protmethod SaveControlState

Saves any server control state changes that have occurred since the time the page was posted back to the server.(Inherited from Control.)

System_CAPS_protmethod 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.)

System_CAPS_protmethod SetDesignModeState

Sets design-time data for a control.(Inherited from Control.)

System_CAPS_pubmethod SetFocus

Sets the browser focus to the specified control.

System_CAPS_pubmethod SetFocus

Sets the browser focus to the control specified by ID.

System_CAPS_pubmethod SetRenderMethodDelegate

This API supports the product infrastructure and is not intended to be used directly from your code. Assigns an event handler delegate to render the server control and its content into its parent control.(Inherited from Control.)

System_CAPS_pubmethod SetTraceData

Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.(Inherited from Control.)

System_CAPS_pubmethod SetTraceData

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

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_protmethod 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 property.(Inherited from Control.)

Events
NameDescription
System_CAPS_pubevent AsyncPostBackError

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

System_CAPS_pubevent DataBinding

Occurs when the server control binds to a data source.(Inherited from Control.)

System_CAPS_pubevent 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.)

System_CAPS_pubevent Init

Occurs when the server control is initialized, which is the first step in its lifecycle.(Inherited from Control.)

System_CAPS_pubevent Load

Occurs when the server control is loaded into the Page object.(Inherited from Control.)

System_CAPS_pubevent Navigate

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

System_CAPS_pubevent PreRender

Occurs after the Control object is loaded but prior to rendering.(Inherited from Control.)

System_CAPS_pubevent ResolveCompositeScriptReference

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

System_CAPS_pubevent ResolveScriptReference

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

System_CAPS_pubevent Unload

Occurs when the server control is unloaded from memory.(Inherited from Control.)

Explicit Interface Implementations
NameDescription
System_CAPS_pubinterface System_CAPS_privmethod IControlDesignerAccessorGetDesignModeState

For a description of this member, see IControlDesignerAccessorGetDesignModeState.(Inherited from Control.)

System_CAPS_pubinterface System_CAPS_privmethod IControlDesignerAccessorSetDesignModeState

For a description of this member, see IControlDesignerAccessorSetDesignModeState. (Inherited from Control.)

System_CAPS_pubinterface System_CAPS_privmethod IControlDesignerAccessorSetOwnerControl

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IControlDesignerAccessorSetOwnerControl. (Inherited from Control.)

System_CAPS_pubinterface System_CAPS_privmethod IParserAccessorAddParsedSubObject

For a description of this member, see IParserAccessorAddParsedSubObject. (Inherited from Control.)

System_CAPS_pubinterface System_CAPS_privmethod IPostBackDataHandlerLoadPostData

For a description of this member, see IPostBackDataHandlerLoadPostData.

System_CAPS_pubinterface System_CAPS_privmethod IPostBackDataHandlerRaisePostDataChangedEvent

For a description of this member, see IPostBackDataHandlerRaisePostDataChangedEvent.

System_CAPS_pubinterface System_CAPS_privmethod IPostBackEventHandlerRaisePostBackEvent

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

System_CAPS_pubinterface System_CAPS_privproperty

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

System_CAPS_pubinterface System_CAPS_privproperty

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

System_CAPS_pubinterface System_CAPS_privproperty

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

System_CAPS_pubinterface System_CAPS_privproperty

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

System_CAPS_pubinterface System_CAPS_privproperty

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

System_CAPS_pubinterface System_CAPS_privproperty

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

Extension Methods
NameDescription
System_CAPS_pubmethod FindDataSourceControl

Returns the data source that is associated with the data control for the specified control.(Defined by DynamicDataExtensions.)

System_CAPS_pubmethod FindFieldTemplate

Returns the field template for the specified column in the specified control's naming container.(Defined by DynamicDataExtensions.)

System_CAPS_pubmethod FindMetaTable

Returns the metatable object for the containing data control.(Defined by DynamicDataExtensions.)

Remarks

In this topic:

  • Introduction

  • Partial-Page Rendering

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

  • Script Management and Registration

  • Web Service References

  • Localization

  • Error Handling

  • Declarative Syntax

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) , , and functions in the browser.

  • Access localization resources for embedded script files or for stand-alone script files by using the 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:

  • The ScriptManager control's property must be true (the default value).

  • There must be at least one UpdatePanel control on the page.

  • The property must be true (the default value). If the property is not set explicitly, its value is based on browser capabilities.

You can override the value of the 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 ASP.NET 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 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 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 collection of the ScriptManager control. ASP.NET generates a client proxy object for each ServiceReference object in the collection. You can programmatically add ServiceReference objects to the 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 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 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 property, the property, and the custom errors section of the Web.config file. For more information, see Customizing Error Handling for ASP.NET 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>
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 property is Always, and the value of the 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 property in the event handler. You can also set the 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 property is used. This means that if the Web.config file contains a 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 property so that client script can display a culture-specific date and time in the browser. In the example, the Culture attribute of the 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>
Version Information
.NET Framework
Available since 3.5
Thread Safety

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

Return to top