Showing posts with label branding. Show all posts
Showing posts with label branding. Show all posts

Thursday, 22 November 2012

SharePoint css registration instead of html link tag

You can use the <SharePoint:CssRegistration...> instead of the traditional html <link...> tag.

Some of the advantages are:
- the order stylesheets are loaded (the after propertiy)
- target it for specific browsers (the ConditionalExpression property)
- avoid that the same stylesheet gets loaded multiple times
- use SPUrl in the link to the stylesheet to refer to the present site collection

Many of theese things can be done with the <link> tag as well. However you might find it easier to do it with the <SharePoint:CssRegistration...>.
To prevent a stylesheet from being loaded multiple times you must use the <SharePoint:CssRegistration...> tag.

CssRegistration vs CssLink

There is also a <SharePoint:CssRegistration...> in SharePoint for registrering stylesheet files, but when to use one or the other?

  • CssLink can be used only in the masterpage. It will list all css files when the page is generated.
  • CssRegistration can be used in masterpages, pagelayouts or content pages. It will only tell SharePoint that this stylesheet must be included as well, but will not render it. CssLink will do the actual rendering.


See this very good article for a thorough workthrough: SharePoint CSSRegistration or Link?
See CssRegistration Class (msdn)
See CssLink Class (msdn) 

Wednesday, 7 November 2012

Custom page title on SharePoint pages

In your pagelayout locate the content place holder called "PlaceHolderPageTitle".


<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">
</asp:Content>

Type your page title inside it

<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">
Contoso | <SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>
</asp:Content>


In this example the page title will be "Contoso | xyz" where xyz is what you have entered in the title field when you are in edit mode of the page.


See also:
Set or Change SharePoint Page Titles (“PlaceHolderPageTitle”)
Change Title Tag on SharePoint Sites