Class JavaScriptExtensions
JavaScript related methods
Inheritance
System.Object
JavaScriptExtensions
Assembly: PnP.Framework.dll
Syntax
public static class JavaScriptExtensions : object
Fields
Default Script Location value
Declaration
public const string SCRIPT_LOCATION = null
Field Value
Methods
Injects javascript via a adding a custom action to the site
Declaration
public static bool AddJsBlock(this Site site, string key, string scriptBlock, int sequence = 0)
Parameters
Site
site
Site to be processed
|
System.String
key
Identifier (key) for the custom action that will be created
|
System.String
scriptBlock
Javascript to be injected
|
System.Int32
sequence
Specifies the ordering priority for actions. A value is 0 indicates that the button will appear at the first position on the ribbon.
|
Returns
System.Boolean
True if action was ok
|
Injects javascript via a adding a custom action to the site
Declaration
public static bool AddJsBlock(this Web web, string key, string scriptBlock, int sequence = 0)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
System.String
key
Identifier (key) for the custom action that will be created
|
System.String
scriptBlock
Javascript to be injected
|
System.Int32
sequence
Specifies the ordering priority for actions. A value is 0 indicates that the button will appear at the first position on the ribbon.
|
Returns
System.Boolean
True if action was ok
|
Injects links to javascript files via a adding a custom action to the site
Declaration
public static bool AddJsLink(this Site site, string key, IEnumerable<string> scriptLinks, int sequence = 0)
Parameters
Site
site
Site to be processed
|
System.String
key
Identifier (key) for the custom action that will be created
|
IEnumerable<System.String>
scriptLinks
IEnumerable list of links to javascript files
|
System.Int32
sequence
Specifies the ordering priority for actions. A value is 0 indicates that the button will appear at the first position on the ribbon.
|
Returns
System.Boolean
True if action was ok
|
Injects links to javascript files via a adding a custom action to the site
Declaration
public static bool AddJsLink(this Site site, string key, string scriptLinks, int sequence = 0)
Parameters
Site
site
Site to be processed
|
System.String
key
Identifier (key) for the custom action that will be created
|
System.String
scriptLinks
semi colon delimited list of links to javascript files
|
System.Int32
sequence
Specifies the ordering priority for actions. A value is 0 indicates that the button will appear at the first position on the ribbon.
|
Returns
System.Boolean
True if action was ok
|
Injects links to javascript files via a adding a custom action to the site
Declaration
public static bool AddJsLink(this Web web, string key, IEnumerable<string> scriptLinks, int sequence = 0)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
System.String
key
Identifier (key) for the custom action that will be created
|
IEnumerable<System.String>
scriptLinks
IEnumerable list of links to javascript files
|
System.Int32
sequence
Specifies the ordering priority for actions. A value is 0 indicates that the button will appear at the first position on the ribbon.
|
Returns
System.Boolean
True if action was ok
|
Injects links to javascript files via a adding a custom action to the site
Declaration
public static bool AddJsLink(this Web web, string key, string scriptLinks, int sequence = 0)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
System.String
key
Identifier (key) for the custom action that will be created
|
System.String
scriptLinks
semi colon delimited list of links to javascript files
|
System.Int32
sequence
Specifies the ordering priority for actions. A value is 0 indicates that the button will appear at the first position on the ribbon.
|
Returns
System.Boolean
True if action was ok
|
Removes the custom action that triggers the execution of a javascript link
Declaration
public static bool DeleteJsLink(this Site site, string key)
Parameters
Site
site
Site to be processed
|
System.String
key
Identifier (key) for the custom action that will be deleted
|
Returns
System.Boolean
True if action was ok
|
Removes the custom action that triggers the execution of a javascript link
Declaration
public static bool DeleteJsLink(this Web web, string key)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
System.String
key
Identifier (key) for the custom action that will be deleted
|
Returns
System.Boolean
True if action was ok
|
Checks if the target site already has a custom JsLink with a specified key
Declaration
public static Boolean ExistsJsLink(this Site site, string key)
Parameters
Site
site
Site to be processed
|
System.String
key
Identifier (key) for the custom action that will be created
|
Returns
Boolean
True if custom JsLink exists, false otherwise
|
Checks if the target web already has a custom JsLink with a specified key
Declaration
public static Boolean ExistsJsLink(this Web web, string key)
Parameters
Web
web
Web to be processed
|
System.String
key
Identifier (key) for the custom action that will be created
|
Returns
Checks if the given clientObject already has a custom JsLink with a specified key
Declaration
public static Boolean ExistsJsLinkImplementation(ClientObject clientObject, string key)
Parameters
ClientObject
clientObject
clientObject to operate on
|
System.String
key
Identifier (key) for the custom action that will be created
|
Returns
Boolean
True if custom JsLink exists, false otherwise
|