My css file is in _layouts/MyProject/css/styles.css and I need to register it from code behind. For this I should use CssRegistration.Register method:
CssRegistration.Register("MyProject/css/styles.css");
But you will get this exception:
Cannot make a cache safe URL for “1033/styles/MyProject/css/styles.css”, file not found. Please verify that the file exists under the layouts directory.
because SharePoint expect the css file in language specific folder e.g. for English 1033/styles.
Seems there is no parameter to turn this behavior off!
On the other hand very similar task, registration of the javascript file, supports such requirement, see the third parameter localizable:
ScriptLink.Register(Page, "MyProject/js/script.js", false);
Why the 2 classes for logically the same thing has so different interface? Is there any way how to register css out of the language specific folder? Or the only way is to distribute the same css file to those LCID folders?
You could instead create a new
CssRegistrationcontrol and add it to the page. Then include the “/_layouts/” folder in the path