CSSRegistrations and ScriptRegistration in SP 2010

The CssRegistration control adds each of the style sheets to an internal collection in the SPContext and the CssLink renders each of them in alphabetical order before rendering the primary, default, and alternate CSS links. If you want one of them to appear after core.css, set the DefaultUrl property of CssLink.

CSSLink Example:

<Sharepoint:CssLink runat="server" DefaultUrl="<% $SPUrl:~SiteCollection/Style Library/en-us/Core Styles/Style.css %>"/>

CssRegistration Example:

<SharePoint:CssRegistration Name="<%$ SPUrl:~sitecollection/Style Library/en-us/Core Styles/Style.css %>"
After="corev4.css" runat="server" EnableCssTheming="true"/>

It’s very easy to get confused by this because the CssRegistration controls are after CssLink, but they don’t render the links, CssLink does!
One advantage that the publishing definitions have over the SharePoint default.master is the $SPUrl expression that allows dynamic creation of the URL for sites under the root web that use the root web’s master pages. Unfortunately, while CssRegistration is part of the core Microsoft.SharePoint.dll, $SPUrl requires the publishing features to be turned on.

For a JS reference, it’s important to note that ScriptLink doesn’t support the expression builders like . If the script available in top-Level site, you can use:

<SharePoint:Scriptlink runat="server" name="~SiteCollection/Style Library/en-us/Core Styles/JS/script1.js" 
language="javscript" />

If the script avaialble in the current site, we can use:

<SharePoint:Scriptlink runat="server" name="~Site/Style Library/en-us/Core Styles/JS/script1.js" 
language="javscript" />

Leave a Reply

I've been low-key stressed about how to view the many email inboxes I have in Outlook in one view without having to scroll and hunt for new messages.

The 'macro' method in this video works great.

View Multiple Inboxes at Once in Outlook 365 https://youtu.be/NpFSsovHgVo via @YouTube

We help Department of Defense clients realize benefits such as faster decision making, total traceability, and automated updates by identifying targeted goals and putting an emphasis on a culture of adoption through buy-in by individual team members.


How to: Create a report quickly from a #SharePoint list or library in the #PowerBI service

Leverage Microsoft Project for the web with the Project Accelerator https://youtu.be/Hxr8dncHmT8 via @YouTube

Load More...