Class ClientScriptUtility
Contains common helper methods for client script generation
Inheritance
Inherited Members
Namespace: EPiServer.ClientScript
Assembly: EPiServer.dll
Version: 9.12.2Syntax
public class ClientScriptUtility
Constructors
ClientScriptUtility()
Declaration
public ClientScriptUtility()
Methods
FindControlRecursive(Control, String)
Find a control by its id in our NamingContainer or any parent NamingContainer
Declaration
public static Control FindControlRecursive(Control baseControl, string controlId)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | baseControl | Control |
System.String | controlId | Id of the control to find |
Returns
Type | Description |
---|---|
System.Web.UI.Control | A reference to the control or null if no matching control |
GenerateClientFunctionStub(String)
Creates a anonymous javascript function from the passed string.
Declaration
public static string GenerateClientFunctionStub(string functionBody)
Parameters
Type | Name | Description |
---|---|---|
System.String | functionBody | The javascript statement used as body for the created function. |
Returns
Type | Description |
---|---|
System.String | A string containing a javascript function returning the result of the passed function body. |
RegisterClientScriptFile(Page, String)
Helper method to register a client script file. If the method is called multiple times using the same key, only a single instance of the file is registered.
Declaration
public static void RegisterClientScriptFile(Page page, string rootRelativePath)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page | The page. |
System.String | rootRelativePath | The root relative path. |
Remarks
The relativePath will be used as the unique script key.
RegisterDialogSupportScripts(Page)
Registers the client scripts required for dialog support. system.aspx, system.js, episerverscriptmanager.js and dialog.js
Declaration
public static void RegisterDialogSupportScripts(Page page)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page | The page where the scripts ar registered. |
ToScriptSafeIdentifier(String)
Make string safe to be used as a identifier in a script block, by replacing any characters that would invalidate the script with script-safe characters.
Declaration
public static string ToScriptSafeIdentifier(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String that needs to be script-safe |
Returns
Type | Description |
---|---|
System.String | Script-safe identifier |
ToScriptSafeString(String)
Make a string safe to be embedded into a script block, by replacing any characters that would invalidate the script with script-safe characters.
Declaration
public static string ToScriptSafeString(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | Text that needs to be script-safe |
Returns
Type | Description |
---|---|
System.String | Script-safe text |