Class ScriptManager
The ScriptManager class is a handler for client side scripts and settings for DOM objects.
Inheritance
Inherited Members
Namespace: EPiServer.ClientScript
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7Syntax
public class ScriptManager
Constructors
ScriptManager()
Declaration
public ScriptManager()
Properties
Current
Get a reference to the ScriptManager for the current page.
Declaration
public static ScriptManager Current { get; }
Property Value
Type | Description |
---|---|
ScriptManager |
Remarks
If the ScriptManger is not available an exception is thrown
HasObjectEventListeners
Gets a value indicating whether this instance has event listeners.
Declaration
protected bool HasObjectEventListeners { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
HasObjectSettings
Gets a value indicating whether this instance has object settings.
Declaration
protected bool HasObjectSettings { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsAvailable
Returns true if the script manager is available for the executing page.
Declaration
public static bool IsAvailable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ObjectEventListeners
Gets a dictionary of configured event listeners.
Declaration
protected Hashtable ObjectEventListeners { get; }
Property Value
Type | Description |
---|---|
System.Collections.Hashtable |
ObjectSettings
Returns a dictionary for storage of object settings.
Declaration
protected ScriptManager.SettingsDictionary ObjectSettings { get; }
Property Value
Type | Description |
---|---|
ScriptManager.SettingsDictionary |
Methods
AddEventListener(String, EventBase)
Add client side event listener to an element.
Declaration
public void AddEventListener(string domNode, EventBase scriptEvent)
Parameters
Type | Name | Description |
---|---|---|
System.String | domNode | The DOM node or id of a DOM node. If this parameter is the id of a DOM node the id must be qouted. |
EventBase | scriptEvent | The script event. |
AddEventListener(String, EventType, String)
Add a client side event listener as a function reference
Declaration
public void AddEventListener(string domNode, EventType eventType, string eventHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | domNode | Name of the node to add an event for. If the name is an id the string must be qouted. |
EventType | eventType | |
System.String | eventHandler | Client side event function reference |
AddEventListener(String, String, String)
Add a custom client side event listener as a function reference
Declaration
public void AddEventListener(string domNode, string eventName, string eventHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | domNode | Name of the node to add an event for. If the name is an id the string must be qouted. |
System.String | eventName | Name of the client side event with the "on" prefix omitted |
System.String | eventHandler | Client side event function reference |
AddEventListener(Control, EventBase)
Add a client side event listener to a control
Declaration
public void AddEventListener(Control control, EventBase scriptEvent)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | control | The control to add an event listener for |
EventBase | scriptEvent |
AddEventListener(Control, EventType, String)
Add a client side event listener as a function reference
Declaration
public void AddEventListener(Control control, EventType eventType, string eventHandler)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | control | The control to add an event listener for |
EventType | eventType | Type of the event. |
System.String | eventHandler | Client side event function reference |
AddEventListener(Control, String, String)
Add a custom client side event listener as a function reference
Declaration
public void AddEventListener(Control control, string eventName, string eventHandler)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | control | The control to add an event listener for |
System.String | eventName | Name of the client side event with the "on" prefix omitted |
System.String | eventHandler | Client side event function reference |
AddSetting(String, String, String)
Add a string setting for a client side object
Declaration
public void AddSetting(string clientId, string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | Client side property identifier |
System.String | name | Client side property name |
System.String | value | Value of the added property |
AddSetting(String, String, String, Boolean)
Adds a setting for a client side object.
Declaration
public void AddSetting(string clientId, string name, string value, bool valueAsObject)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | Client side identifier of the element to set the property for |
System.String | name | Client side property name |
System.String | value | Value of the added property |
System.Boolean | valueAsObject | if set to |
AddSetting(String, String, String, String, Boolean)
Adds a setting for a client side object.
Declaration
public void AddSetting(string domNode, string objectKey, string name, string value, bool valueAsObject)
Parameters
Type | Name | Description |
---|---|---|
System.String | domNode | The name of a DOM node or the qouted id of a DOM node |
System.String | objectKey | Container key for the added setting |
System.String | name | Client side property name |
System.String | value | Value of the added property |
System.Boolean | valueAsObject | if set to |
AddSetting(Control, String, String)
Add a string setting for a System.Web.UI.Control to the controls script object
Declaration
public void AddSetting(Control control, string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | control | The control to add setting for |
System.String | name | Client side property name |
System.String | value | Value of the added property |
AddSetting(Control, String, String, Boolean)
Adds a setting for a client side object.
Declaration
public void AddSetting(Control control, string name, string value, bool valueAsObject)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | control | The control to add setting for |
System.String | name | Client side property name |
System.String | value | Value of the added property |
System.Boolean | valueAsObject | if set to |
RegisterClientScriptBlocks(Page)
Appends clients scripts to the page. This method is intended to be called from the page as late as possible in its life cycle
Declaration
public virtual void RegisterClientScriptBlocks(Page page)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page | The page instance to append scripts to |
RegisterClientScriptIncludes(Page)
Registers the dependant client script includes.
Declaration
protected void RegisterClientScriptIncludes(Page page)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page | A reference to the active page. |
RenderClientScriptBlocks(TextWriter)
Renders the client script blocks to a System.IO.TextWriter.
Declaration
public virtual void RenderClientScriptBlocks(TextWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.IO.TextWriter | writer | The writer to append script blocks to. |
Remarks
No surrounding script tags are emitted to the writer.
RenderClientScriptBlocks(TextWriter, Boolean)
Renders the client script blocks to a System.IO.TextWriter.
Declaration
public virtual void RenderClientScriptBlocks(TextWriter writer, bool includeExecutor)
Parameters
Type | Name | Description |
---|---|---|
System.IO.TextWriter | writer | The writer to append script blocks to. |
System.Boolean | includeExecutor | If set, append a function which calls both setup property objects and setup events |
Remarks
No surrounding script tags are emitted to the writer.