Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm working on a custom Blog site template that's quite similar to the OOTB Blog site template. I'm having issues with CSS registration of the OOTB blog.css file. (i.e. via Microsoft.SharePoint.WebControls.CssRegistration, with causes the CSS link to be generated by a <SharePoint:CssLink /> element.)

The OOTB template appears to be registering blog.css, and causing a <link> to be rendered, on several pages. I can see CssStyleSheet properties on its View elements in the Posts list's schema.xml which I assume are the way it is registering the CSS.

My template (which was written by someone else and has been migrated from 2007 to 2010) appears to be registering blog.css, and causing a <link> to be rendered, only on the site's home page, but I can't figure out how. There are no CssStyleSheet properties on its View elements. (Indeed, there is no reference to blog.css in the entire solution.) If I add these properties, nothing changes (after creating a new site from the template).

Edit: This is incorrect; I just didn't add the properties on enough View elements. I now know the correct way to register the CSS I want, in order to match the way the OOTB registers it. However, I'll leave this question here, as being able to hook into CssRegistration would still be useful.

Is there a way I can observe how and where CSS files are being registered, so I can compare my template to the OOTB template and get my CSS registered properly?

(I've tried using Reflector to decompile Microsoft.SharePoint.dll and set breakpoints on the relevant code, but a lot of the code was optimized out and I didn't get much insight.)

share|improve this question
Have you tried pressing F12 and inspected the elements and through that checked where the styles appears to come from? –  Daniel Ziga Sep 28 '11 at 11:21
Yes. One symptom of this is that the non-home pages are styled incorrectly, and I used F12 to find that the reason for this was the missing blog.css (themed) reference. (i.e. F12 tells me that the style I want should be coming from blog.css, and F12 also tells me that blog.css is not referenced in the non-home pages.) –  Rawling Sep 28 '11 at 12:20
I've found, at least, why blog.css is being registered on my main page and not the others: the Blog Tools webpart appears to be registering it, and this only appears on the main page of my template. However, this is not the only way it is registered on the default template, so I still need a way to hook into the CSS registration and see how it is done. –  Rawling Oct 3 '11 at 8:10
add comment

1 Answer

If the solution was migrated from 2007 to 2010, there could be a number of things going on.

How/where is your custom template calling the blog.css? Migration of site templates from 2007 to 2010 is a bit of a sticky subject, as it traditionally doesn't work. The typical approach has to be to create a site in 2007 using the template, migrate the site to 2010, then create a 2010 site template from the migrated 2010 site.

If the site was upgraded to the 2010 (v4) look and feel, then it'll no longer be using the 2007 master pages or layouts, and if that's where your custom CSS registration was being called, that'd explain why it's no longer there. The registration method could have been happening a number of ways, have you validated that there is/isn't a CSS link tag being rendered that's looking for the blog.css? It could be a case of the registration being there but pointing to the wrong place (though I don't believe that file moved).

It could just simply be a case of one of your modifications being removed in the migration process so it's no longer registering the CSS.

share|improve this answer
"How/where is your custom template calling the blog.css?" : this is part of the problem. I can't find anywhere it's being called - I don't believe there is a blog.css in 2007, and I've not added any reference to blog.css in the migration work, to the template or to the masters - but it is still appearing (i.e. link being rendered) on the home page, and only the home page, of the blog in 2010. I want to find out why that's happening, so I can make it happen no the other pages too. I've tried duplicating the way the OOTB blog site references blog.css, but it doesn't have any effect. –  Rawling Sep 29 '11 at 7:35
It is most likely being rendered by the blog page layout. If you're seeing it on one page but not another the delta between two (if there's no customization) is most likely the page layout. –  webdes03 Sep 29 '11 at 13:12
By layout do you mean the aspx? None of the aspx files contain a reference to blog.css directly. It may be that one of the pages contains e.g. a webpart that uses CssRegistration to reference blog.css, but that just comes back to "how can I debug CssRegistration to find what's causing the CSS to be referenced?" –  Rawling Sep 29 '11 at 13:41
A page layout is the layer on top of the master page. Page layouts will often use the AdditionalPageHead placeholder to push styles needed for that specific page layout into the master (either straight CSS markup, or registration of external CSS files). Just because you don't see it in your master doesn't mean it's not added dynamically at runtime. There's some good background in this thread of how everything comes together: sharepoint.stackexchange.com/questions/20229/… –  webdes03 Sep 29 '11 at 16:15
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.