<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _ <AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _ <SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _ <AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _ Public NotInheritable Class CssRegistration Inherits SPControl
Dim instance As CssRegistration
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] [AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] [AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class CssRegistration : SPControl
Pages and controls register specific style sheets using <SharePoint:CssRegistration name="filename" or the static CssRegistration.Register("filename") method. The cascading style sheet can be registered as a leaf filename or as a URL.
When the page is assembled, all of the style sheets are brought together and rendered by the CssLink control.
The CssRegistration controls may be placed on a master page, page layout, or content page.
<SharePoint:CSSRegistration name="<% $SPrl:~SiteCollection/Style Library/~language/Core Stypes/Band.css%>" runat="server"/>
The CssRegistration class registers a cascading style sheet (CSS) file with a page by adding a HTML LINK element to the output HTML for that page. The browser that renders the page then applies any styles defined in the CSS file to that page. You can use the CssRegistration class declaratively or programmatically. To use the class declaratively you add markup to the ASP .NET page markup. Alternatively, you can use the class programmatically by using the methods exposed by the class in C# or Visual Basic .NET.
You will typically use this class to register additional CSS files with a page. Registering the CSS file with the page will ensure that any controls that you have configured to use styles defined in your style sheet use the correct styles.
The following code samples show how to register a CSS file named CustomCss.css with your page.
<SharePoint:CSSRegistration name=”CustomCss.css” runat=”server” />
CssRegistration.Register(“CustomCss.css”);
CssRegistration.Register(“CustomCss.css”)
It seems if you are to use CssRegistration.Register with two different URLs:
C#
CssRegistration.Register(@"/Style Library/WebParts/PeopleDetails/style.css");
CssRegistration.Register(@"/Style Library/WebParts/OtherWebPart/style.css");
...only the first one will register on the page. It seems as though the register method code extracts the leaf filename from the url (style.css) to check for duplicate registrations, rather than using the whole Url.