1

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.)

6
  • Have you tried pressing F12 and inspected the elements and through that checked where the styles appears to come from?
    – user2536
    Commented Sep 28, 2011 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
    Commented Sep 28, 2011 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
    Commented Oct 3, 2011 at 8:10
  • @Rawling This is an almost three year old questiuon, but I still think it's valid. Could you add your findings as answer, and mark it as accepted - it would greatly help other users. Thank You!
    – Benny Skogberg
    Commented Aug 21, 2014 at 6:51
  • @Benny Sorry, I wish I could remember what I was talking about :-/
    – Rawling
    Commented Aug 21, 2014 at 7:32

1 Answer 1

-1

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.

4
  • "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
    Commented Sep 29, 2011 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
    Commented Sep 29, 2011 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
    Commented Sep 29, 2011 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
    Commented Sep 29, 2011 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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