Compartilhar via


ScriptLink class

Provides properties and methods for registering resources, such as scripts, on a page so that they can be requested when the page is rendered.

Inheritance hierarchy

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.ScriptLink

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class ScriptLink _
    Inherits SPControl
'Usage
Dim instance As ScriptLink
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ScriptLink : SPControl

Remarks

If you register a .js file by adding a ScriptLink control to an .aspx page, the control registers all .js dependencies. To import the various "SP" namespaces, such as those listed at ECMAScript Object Model Reference, you must register the control as an on-demand script by specifying OnDemand="true". When you register the script, use the SP.SOD.execute or SP.SOD.executeFunc method to execute the script.

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.

See also

Reference

ScriptLink members

Microsoft.SharePoint.WebControls namespace