Share via


ScriptLink.RegisterCore method (Page, Boolean)

Registers the core.js file.

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

Syntax

'Declaration
Public Shared Sub RegisterCore ( _
    page As Page, _
    defer As Boolean _
)
'Usage
Dim page As Page
Dim defer As BooleanScriptLink.RegisterCore(page, defer)
public static void RegisterCore(
    Page page,
    bool defer
)

Parameters

  • defer
    Type: System.Boolean

    Indicates whether to defer downloading the core.js file, that is, to fetch core.js asynchronously.

Remarks

The following example shows how to build a new page layout which does not reference core.js, but downloads it while the page is being viewed, thereby optimizing response time. For more information, see the entry Building a New Page Layout… in the Microsoft Enterprise Content Management team blog.

Examples

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;

namespace WebControls
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:RegisterCoreWhenAuthenticatedControl runat=server></{0}:RegisterCoreWhenAuthenticatedControl>")]

    public class RegisterCoreWhenAuthenticatedControl : WebControl
    {
        protected override void OnInit(EventArgs e)
        {
   if (HttpContext.Current.Request.IsAuthenticated)
   {
        Microsoft.SharePoint.WebControls.ScriptLink.RegisterCore(this.Page, true);
   }
   base.OnInit(e);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Microsoft.SharePoint

Namespace WebControls
    <DefaultProperty("Text"), ToolboxData("<{0}:RegisterCoreWhenAuthenticatedControl runat=server></{0}:RegisterCoreWhenAuthenticatedControl>")> _
    Public Class RegisterCoreWhenAuthenticatedControl
        Inherits WebControl
        Protected Overrides Sub OnInit(ByVal e As EventArgs)
   If HttpContext.Current.Request.IsAuthenticated Then
        Microsoft.SharePoint.WebControls.ScriptLink.RegisterCore(Me.Page, True)
   End If
   MyBase.OnInit(e)
        End Sub
    End Class
End Namespace

See also

Reference

ScriptLink class

ScriptLink members

RegisterCore overload

Microsoft.SharePoint.WebControls namespace