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 making a custom master page with a custom CSS file, being deployed in a feature form VS2010. I'm using the CssRegistation control to add the new CSS, but whenever I try to load a page that uses it, I get an "Illegal characters in path" exception. Which is odd, because there aren't any illegal characters that I can see in the path.

The code I'm using to add the CSS to the page looks like this (from MSDN):

<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/myfolder/mystyle.css %>"  After="corev4.css" runat="server"/>

I've check the relevant galleries and the master page is deploying correctly to _layouts/masterpage/mymaster.master, and the CSS is deploying correctly to Style Library/myfolder/mystyle.css.

What have I missed?

share|improve this question
add comment

3 Answers 3

Have you tried changing "Style Library" to "Style%20Library"?

share|improve this answer
    
Doesn't work - '%' is an illegal character when explicitly declared in the path. –  Moray Jun 27 '12 at 7:35
    
Shot in the dark. –  RJ Cuthbertson Jun 27 '12 at 17:47
add comment

According to this blog post, you will have that issue if you are using SharePoint Foundation: http://blogs.msdn.com/b/sharepointdesigner/archive/2010/04/09/working-with-the-sharepoint-theming-engine.aspx. In SPF you need to hard code the URL.

share|improve this answer
    
Yes that's right. The <% $SPUrl ~sitecollection token is part of the Publishing Infrastructure which is not available in SharePoint Foundation. But did @Moray mention that he/she is using foundation? –  Vardhaman Deshpande Jun 26 '12 at 15:49
    
I'm using SharePoint Standard. –  Moray Jun 27 '12 at 7:53
add comment
up vote 0 down vote accepted

I'm an idiot. The error was coming from an old CssRegistration control that I hadn't commented out properly...

share|improve this answer
    
Happens to the best of us. –  RJ Cuthbertson Jun 27 '12 at 17:47
add comment

Your Answer

 
discard

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.