This topic has not yet been rated - Rate this topic

ScriptLink.RegisterCore Method

Registers the core.js file.

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
public static void RegisterCore(
	Page page,
	bool defer
)

Parameters

page
Type: System.Web.UI.Page
The application page.
defer
Type: System.Boolean
Indicates whether to defer downloading the core.js file, that is, to fetch core.js asynchronously.

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.

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);
        }
    }
}
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ