.NET Framework Class Library
ScriptManager Class

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

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

Namespace:   System.Web.UI
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
Syntax
Public Class ScriptManager _
	Inherits [%$TOPIC/bb344905_en-us_VS_110_2_0_0_0_0%] _
	Implements [%$TOPIC/bb344905_en-us_VS_110_2_0_0_0_1%], [%$TOPIC/bb344905_en-us_VS_110_2_0_0_0_2%]
public class ScriptManager : [%$TOPIC/bb344905_en-us_VS_110_2_0_1_0_0%], 
	[%$TOPIC/bb344905_en-us_VS_110_2_0_1_0_1%], [%$TOPIC/bb344905_en-us_VS_110_2_0_1_0_2%]
public ref class ScriptManager : public [%$TOPIC/bb344905_en-us_VS_110_2_0_2_0_0%], 
	[%$TOPIC/bb344905_en-us_VS_110_2_0_2_0_1%], [%$TOPIC/bb344905_en-us_VS_110_2_0_2_0_2%]
type ScriptManager =  
    class 
        inherit [%$TOPIC/bb344905_en-us_VS_110_2_0_3_0_0%] 
        interface [%$TOPIC/bb344905_en-us_VS_110_2_0_3_0_1%] 
        interface [%$TOPIC/bb344905_en-us_VS_110_2_0_3_0_2%] 
    end
<asp:ScriptManager />

The ScriptManager type exposes the following members.

Constructors
  NameDescription
Public method ScriptManagerInitializes a new instance of the ScriptManager class.
Top
Properties
  NameDescription
Protected property AdapterGets the browser-specific adapter for the control. (Inherited from Control.)
Public property AjaxFrameworkAssemblyGets the Ajax framework assembly that components on the page use.
Public property AjaxFrameworkModeGets or sets a value that specifies how client scripts of the Microsoft Ajax client library will be included on the client.
Public property AllowCustomErrorsRedirectGets 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.
Public property AppRelativeTemplateSourceDirectoryGets or sets the application-relative virtual directory of the Page or UserControl object that contains this control. (Inherited from Control.)
Public property AsyncPostBackErrorMessageGets or sets the error message that is sent to the client when an unhandled server exception occurs during an asynchronous postback.
Public property AsyncPostBackSourceElementIDGets the unique ID of the control that caused the asynchronous postback.
Public property AsyncPostBackTimeoutGets or sets a value that indicates the time, in seconds, before asynchronous postbacks time out if no response is received.
Public property AuthenticationServiceGets the AuthenticationServiceManager object that is associated with the current ScriptManager instance.
Public property BindingContainerInfrastructure. Gets the control that contains this control's data binding. (Inherited from Control.)
Protected property ChildControlsCreatedGets a value that indicates whether the server control's child controls have been created. (Inherited from Control.)
Public property ClientIDGets the control ID for HTML markup that is generated by ASP.NET. (Inherited from Control.)
Public property ClientIDModeGets or sets the algorithm that is used to generate the value of the ClientID property. (Inherited from Control.)
Protected property ClientIDSeparatorGets a character value representing the separator character used in the ClientID property. (Inherited from Control.)
Public property ClientNavigateHandlerGets or sets the name of the method that handles the Sys.Application.navigate event on the client.
Public property CompositeScriptGets a reference to the composite script that supports the Web page.
Protected property ContextGets the HttpContext object associated with the server control for the current Web request. (Inherited from Control.)
Public property ControlsGets a ControlCollection object that represents the child controls for a specified server control in the UI hierarchy. (Inherited from Control.)
Public property DataItemContainerGets a reference to the naming container if the naming container implements IDataItemContainer. (Inherited from Control.)
Public property DataKeysContainerGets a reference to the naming container if the naming container implements IDataKeysControl. (Inherited from Control.)
Protected property DesignModeGets a value indicating whether a control is being used on a design surface. (Inherited from Control.)
Public property EmptyPageUrlGets or sets a URL to a blank Web page.
Public property EnableCdnDetermines whether the current page loads client script references from CDN (Content Delivery Network) paths.
Public property EnableCdnFallbackEnables local copy of a script to load in the event that the CDN (Content Delivery Network) is unavailable.
Public property EnableHistoryGets or sets a value that indicates whether the Web page supports history point management.
Public property EnablePageMethodsGets or sets a value that indicates whether public static page methods in an ASP.NET page can be called from client script.
Public property EnablePartialRenderingGets 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.
Public property EnableScriptGlobalizationGets or sets a value that indicates whether the ScriptManager control renders script that supports parsing and formatting of culture-specific information.
Public property EnableScriptLocalizationGets or sets a value that indicates whether the ScriptManager control renders localized versions of script files.
Public property EnableSecureHistoryStateGets or sets a value that indicates whether to encrypt the history state string.
Public property EnableThemingGets or sets a value indicating whether themes apply to this control. (Inherited from Control.)
Public property EnableViewStateGets 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.)
Protected property EventsGets a list of event handler delegates for the control. This property is read-only. (Inherited from Control.)
Protected property HasChildViewStateGets a value indicating whether the current server control's child controls have any saved view-state settings. (Inherited from Control.)
Public property IDGets or sets the programmatic identifier assigned to the server control. (Inherited from Control.)
Protected property IdSeparatorInfrastructure. Gets the character used to separate control identifiers. (Inherited from Control.)
Protected property IsChildControlStateClearedGets a value indicating whether controls contained within this control have control state. (Inherited from Control.)
Public property IsDebuggingEnabledGets a value that indicates whether the debug versions of client script libraries will be rendered.
Public property IsInAsyncPostBackGets a value that indicates whether the current postback is being executed in partial-rendering mode.
Public property IsNavigatingGets a value that indicates whether a Navigate event is currently being handled.
Protected property IsTrackingViewStateGets a value that indicates whether the server control is saving changes to its view state. (Inherited from Control.)
Protected property IsViewStateEnabledGets a value indicating whether view state is enabled for this control. (Inherited from Control.)
Public property LoadScriptsBeforeUIGets or sets a value that indicates whether scripts are loaded before or after markup for the page UI is loaded.
Protected property LoadViewStateByIDGets a value indicating whether the control participates in loading its view state by ID instead of index. (Inherited from Control.)
Public property NamingContainerGets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ControlID property value. (Inherited from Control.)
Public property PageGets a reference to the Page instance that contains the server control. (Inherited from Control.)
Public property ParentGets a reference to the server control's parent control in the page control hierarchy. (Inherited from Control.)
Public property ProfileServiceGets the ProfileServiceManager object that is associated with the current ScriptManager instance.
Public property RenderingCompatibilityGets a value that specifies the ASP.NET version that rendered HTML will be compatible with. (Inherited from Control.)
Public property RoleServiceGets the RoleServiceManager object that is associated with the current ScriptManager instance.
Public property ScriptModeGets or sets a value that specifies whether debug or release versions of client script libraries are rendered.
Public property ScriptPathObsolete. Gets or sets the root path of the location that is used to build the paths to ASP.NET Ajax and custom script files.
Public property Static member ScriptResourceMappingGets a ScriptResourceMapping object.
Public property ScriptsGets a ScriptReferenceCollection object that contains the ScriptReference objects, each of which represents a script file rendered to the client.
Public property ServicesGets a ServiceReferenceCollection object that contains a ServiceReference object for each Web service that ASP.NET exposes on the client for Ajax functionality.
Public property SiteGets information about the container that hosts the current control when rendered on a design surface. (Inherited from Control.)
Public property SkinIDGets or sets the skin to apply to the control. (Inherited from Control.)
Public property SupportsPartialRenderingGets a value that indicates whether the client supports partial-page rendering.
Public property TemplateControlGets or sets a reference to the template that contains this control. (Inherited from Control.)
Public property TemplateSourceDirectoryGets the virtual directory of the Page or UserControl that contains the current server control. (Inherited from Control.)
Public property UniqueIDGets the unique, hierarchically qualified identifier for the server control. (Inherited from Control.)
Public property ValidateRequestModeGets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values. (Inherited from Control.)
Protected property ViewStateGets 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.)
Protected property ViewStateIgnoresCaseGets a value that indicates whether the StateBag object is case-insensitive. (Inherited from Control.)
Public property ViewStateModeGets or sets the view-state mode of this control. (Inherited from Control.)
Public property VisibleOverrides the Visible property that is inherited from the base Control class to prevent setting this value. (Overrides ControlVisible.)
Top
Methods
  NameDescription
Protected method AddedControlCalled after a child control is added to the Controls collection of the Control object. (Inherited from Control.)
Public method 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.
Public method AddHistoryPoint(String, String)Creates a history point and adds it to the browser's history stack, using the specified state key and state value.
Public method 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.
Protected method AddParsedSubObjectNotifies 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.)
Public method ApplyStyleSheetSkinApplies the style properties defined in the page style sheet to the control. (Inherited from Control.)
Protected method BeginRenderTracingBegins design-time tracing of rendering data. (Inherited from Control.)
Protected method BuildProfileTreeInfrastructure. 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.)
Protected method ClearCachedClientIDInfrastructure. Sets the cached ClientID value to . (Inherited from Control.)
Protected method ClearChildControlStateDeletes the control-state information for the server control's child controls. (Inherited from Control.)
Protected method ClearChildStateDeletes the view-state and control-state information for all the server control's child controls. (Inherited from Control.)
Protected method ClearChildViewStateDeletes the view-state information for all the server control's child controls. (Inherited from Control.)
Protected method ClearEffectiveClientIDModeInfrastructure. Sets the ClientIDMode property of the current control instance and of any child controls to Inherit. (Inherited from Control.)
Protected method CreateChildControlsCalled 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.)
Protected method CreateControlCollectionCreates a new ControlCollection object to hold the child controls (both literal and server) of the server control. (Inherited from Control.)
Public method DataBindBinds a data source to the invoked server control and all its child controls. (Inherited from Control.)
Protected method 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.)
Protected method DataBindChildrenBinds a data source to the server control's child controls. (Inherited from Control.)
Public method DisposeEnables a server control to perform final clean up before it is released from memory. (Inherited from Control.)
Protected method EndRenderTracingEnds design-time tracing of rendering data. (Inherited from Control.)
Protected method EnsureChildControlsDetermines whether the server control contains child controls. If it does not, it creates child controls. (Inherited from Control.)
Protected method EnsureIDCreates an identifier for controls that do not have an identifier assigned. (Inherited from Control.)
Public method Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method FindControl(String)Searches the current naming container for a server control with the specified id parameter. (Inherited from Control.)
Protected method FindControl(String, Int32)Infrastructure. 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.)
Public method FocusSets input focus to a control. (Inherited from Control.)
Public method Static member GetCurrentGets the ScriptManager instance for a given Page object.
Protected method GetDesignModeStateInfrastructure. Gets design-time data for a control. (Inherited from Control.)
Public method GetHashCodeServes as the default hash function. (Inherited from Object.)
Public method GetRegisteredArrayDeclarationsRetrieves a read-only collection of ECMAScript (JavaScript) array declarations that were previously registered with the Page object.
Public method GetRegisteredClientScriptBlocksRetrieves a read-only collection of client script blocks that were previously registered with the ScriptManager control.
Public method GetRegisteredDisposeScriptsRetrieves a read-only collection of dispose scripts that were previously registered with the Page object.
Public method GetRegisteredExpandoAttributesRetrieves a read-only collection of custom (expando) attributes that were previously registered with the Page object.
Public method GetRegisteredHiddenFieldsRetrieves a read-only collection of hidden fields that were previously registered with the Page object.
Public method GetRegisteredOnSubmitStatementsRetrieves a read-only collection of onsubmit statements that were previously registered with the Page object.
Public method GetRegisteredStartupScriptsRetrieves a read-only collection of startup scripts that were previously registered with the Page object.
Public method GetRouteUrl(Object)Gets the URL that corresponds to a set of route parameters. (Inherited from Control.)
Public method GetRouteUrl(RouteValueDictionary)Gets the URL that corresponds to a set of route parameters. (Inherited from Control.)
Public method GetRouteUrl(String, Object)Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.)
Public method GetRouteUrl(String, RouteValueDictionary)Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.)
Public method GetStateStringRetrieves a string that contains key/value pairs that represent the state of the Web page.
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method GetUniqueIDRelativeToReturns the prefixed portion of the UniqueID property of the specified control. (Inherited from Control.)
Public method HasControlsDetermines if the server control contains any child controls. (Inherited from Control.)
Protected method HasEventsReturns a value indicating whether events are registered for the control or any child controls. (Inherited from Control.)
Protected method IsLiteralContentInfrastructure. Determines if the server control holds only literal content. (Inherited from Control.)
Protected method LoadControlStateRestores control-state information from a previous page request that was saved by the SaveControlState method. (Inherited from Control.)
Protected method LoadPostDataReads form data that is posted from the browser to the server, and determines the source of the asynchronous postback.
Protected method LoadViewStateRestores view-state information from a previous page request that was saved by the SaveViewState method. (Inherited from Control.)
Protected method MapPathSecureRetrieves the physical path that a virtual path, either absolute or relative, maps to. (Inherited from Control.)
Protected method MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnAsyncPostBackErrorRaises the AsyncPostBackError event.
Protected method OnBubbleEventDetermines whether the event for the server control is passed up the page's UI server control hierarchy. (Inherited from Control.)
Protected method OnDataBindingRaises the DataBinding event. (Inherited from Control.)
Protected method OnInitRaises the Init event and makes sure that only one ScriptManager control exists on the page. (Overrides ControlOnInit(EventArgs).)
Protected method OnLoadRaises the Load event. (Inherited from Control.)
Protected method OnPreRenderRaises the PreRender event, and registers script files and services for partial-page updates. (Overrides ControlOnPreRender(EventArgs).)
Protected method OnResolveCompositeScriptReferenceRaises the ResolveCompositeScriptReference event.
Protected method OnResolveScriptReferenceRaises the ResolveScriptReference event for each script reference that is managed by the ScriptManager control.
Protected method OnUnloadRaises the Unload event. (Inherited from Control.)
Protected method OpenFileGets a Stream used to read a file. (Inherited from Control.)
Protected method RaiseBubbleEventAssigns any sources of the event and its information to the control's parent. (Inherited from Control.)
Protected method RaisePostBackEventProcesses a postback event raised by the ScriptManager control and loads the history state of the Web page.
Protected method RaisePostDataChangedEventRaises events for the ScriptManager control when it posts back to the server.
Public method Static member 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.
Public method Static member 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.
Public method RegisterAsyncPostBackControlRegisters a control as a trigger for asynchronous postbacks.
Public method Static member 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.
Public method Static member 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.
Public method Static member 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.
Public method Static member 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.
Public method Static member 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.
Public method Static member 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.
Public method RegisterDataItem(Control, String)Sends custom data to a control during partial-page rendering.
Public method 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.
Public method RegisterDisposeRegisters a dispose script for a control that is inside an UpdatePanel control. The script is executed when the UpdatePanel control is updated or deleted.
Public method Static member RegisterExpandoAttributeRegisters a name/value pair with the ScriptManager control as a custom (expando) attribute of a specified control.
Public method RegisterExtenderControlTExtenderControlRegisters an extender control with the current ScriptManager instance.
Public method Static member RegisterHiddenField(Control, String, String)Registers a hidden field with the ScriptManager control for a control that is inside an UpdatePanel control.
Public method Static member RegisterHiddenField(Page, String, String)Registers a hidden field with the ScriptManager control during every asynchronous postback.
Public method Static member 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.
Public method Static member 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.
Public method Static member 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.
Public method Static member 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.
Public method RegisterPostBackControlRegisters 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.
Public method RegisterScriptControlTScriptControlRegisters a script control with the current ScriptManager instance.
Public method 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.
Public method 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.
Public method Static member 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.
Public method Static member 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.
Protected method RemovedControlCalled after a child control is removed from the Controls collection of the Control object. (Inherited from Control.)
Protected method RenderRenders the ScriptManager control's content to the browser by using the specified HtmlTextWriter object. (Overrides ControlRender(HtmlTextWriter).)
Protected method RenderChildrenOutputs 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.)
Public method 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.)
Protected method RenderControl(HtmlTextWriter, ControlAdapter)Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object. (Inherited from Control.)
Protected method ResolveAdapterGets the control adapter responsible for rendering the specified control. (Inherited from Control.)
Public method ResolveClientUrlGets a URL that can be used by the browser. (Inherited from Control.)
Public method ResolveUrlConverts a URL into one that is usable on the requesting client. (Inherited from Control.)
Protected method SaveControlStateSaves any server control state changes that have occurred since the time the page was posted back to the server. (Inherited from Control.)
Protected method SaveViewStateSaves any server control view-state changes that have occurred since the time the page was posted back to the server. (Inherited from Control.)
Protected method SetDesignModeStateSets design-time data for a control. (Inherited from Control.)
Public method SetFocus(Control)Sets the browser focus to the specified control.
Public method SetFocus(String)Sets the browser focus to the control specified by ID.
Public method SetRenderMethodDelegateInfrastructure. Assigns an event handler delegate to render the server control and its content into its parent control. (Inherited from Control.)
Public method 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.)
Public method 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.)
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Protected method TrackViewStateCauses 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 ControlViewState property. (Inherited from Control.)
Top
Events
  NameDescription
Public event AsyncPostBackErrorOccurs when there is a page error during an asynchronous postback.
Public event DataBindingOccurs when the server control binds to a data source. (Inherited from Control.)
Public event DisposedOccurs 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.)
Public event InitOccurs when the server control is initialized, which is the first step in its lifecycle. (Inherited from Control.)
Public event LoadOccurs when the server control is loaded into the Page object. (Inherited from Control.)
Public event NavigateOccurs when the user clicks the browser's Back or Forward button.
Public event PreRenderOccurs after the Control object is loaded but prior to rendering. (Inherited from Control.)
Public event ResolveCompositeScriptReferenceOccurs when a composite script is registered with the ScriptManager control.
Public event ResolveScriptReferenceOccurs when a member of the Scripts collection is registered with the ScriptManager control.
Public event UnloadOccurs when the server control is unloaded from memory. (Inherited from Control.)
Top
Extension Methods
  NameDescription
Public Extension Method FindDataSourceControlReturns the data source that is associated with the data control for the specified control. (Defined by DynamicDataExtensions.)
Public Extension Method FindFieldTemplateReturns the field template for the specified column in the specified control's naming container. (Defined by DynamicDataExtensions.)
Public Extension Method FindMetaTableReturns the metatable object for the containing data control. (Defined by DynamicDataExtensions.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private property IControlBuilderAccessorControlBuilderFor a description of this member, see IControlBuilderAccessorControlBuilder. (Inherited from Control.)
Explicit interface implemetation Private method IControlDesignerAccessorGetDesignModeStateFor a description of this member, see IControlDesignerAccessorGetDesignModeState. (Inherited from Control.)
Explicit interface implemetation Private method IControlDesignerAccessorSetDesignModeStateFor a description of this member, see IControlDesignerAccessorSetDesignModeState. (Inherited from Control.)
Explicit interface implemetation Private method IControlDesignerAccessorSetOwnerControlInfrastructure. For a description of this member, see IControlDesignerAccessorSetOwnerControl. (Inherited from Control.)
Explicit interface implemetation Private property IControlDesignerAccessorUserDataFor a description of this member, see IControlDesignerAccessorUserData. (Inherited from Control.)
Explicit interface implemetation Private property IDataBindingsAccessorDataBindingsFor a description of this member, see IDataBindingsAccessorDataBindings. (Inherited from Control.)
Explicit interface implemetation Private property IDataBindingsAccessorHasDataBindingsFor a description of this member, see IDataBindingsAccessorHasDataBindings. (Inherited from Control.)
Explicit interface implemetation Private property IExpressionsAccessorExpressionsFor a description of this member, see IExpressionsAccessorExpressions. (Inherited from Control.)
Explicit interface implemetation Private property IExpressionsAccessorHasExpressionsFor a description of this member, see IExpressionsAccessorHasExpressions. (Inherited from Control.)
Explicit interface implemetation Private method IParserAccessorAddParsedSubObjectFor a description of this member, see IParserAccessorAddParsedSubObject. (Inherited from Control.)
Explicit interface implemetation Private method IPostBackDataHandlerLoadPostDataFor a description of this member, see IPostBackDataHandlerLoadPostData.
Explicit interface implemetation Private method IPostBackDataHandlerRaisePostDataChangedEventFor a description of this member, see IPostBackDataHandlerRaisePostDataChangedEvent.
Explicit interface implemetation Private method IPostBackEventHandlerRaisePostBackEventEnables the ScriptManager control to process a postback event and load the history state of the Web page.
Top
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) 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 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

RegisterScriptControlTScriptControl

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.

RegisterExtenderControlTExtenderControl

Registers a server control that implements the IExtenderControl interface that is used to define a Sys.UI.Behavior 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 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 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="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>

<%@ 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>

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="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>
<%@ 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>

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="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>
<%@ 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>
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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.