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

Full error:

Cannot make a cache safe URL for "sprocketcomplete/layouts/sprocketcomplete/js/sprocketcomplete.js", file not found. Please verify that the file exists under the layouts directory.

I have added a Mapped Folder for Layouts. My JS files are set to Build Action: Content and Copy to Output Directory: Copy always.

I also set Localizable on my ScriptLink tag to false

Has anyone seen this error before? Is there something I should be doing to make this work?

UPDATE:

This is a webfarm solution, not a sandbox solution.

On my file system the js files are located at:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SprocketComplete\js\

Here is my ScriptLink tags:

<SharePoint:ScriptLink ID="ScriptLink5" runat="server" Name="SprocketComplete/js/sprocketComplete.js" Localizable="false"/>
<SharePoint:ScriptLink ID="ScriptLink3" runat="server" Name="SprocketComplete/js/jquery.autocomplete.min.js" Defer="true" Localizable="false" />
<SharePoint:ScriptLink ID="ScriptLink4" runat="server" Name="SprocketComplete/js/lib/jquery.bgiframe.min.js" Defer="true" Localizable="false" />
<SharePoint:ScriptLink ID="ScriptLink2" runat="server" Name="SprocketComplete/js/jquery.min.js" Defer="true" Localizable="false" />

UPDATE 2:

I tried changing the path to my js as @Djeeg suggested, but now nothing happens. Below is my javascript. It seems like "test" should pop up (also, I am including a jQuery library the same way I am including sprocketComplete.js)

$(document).ready(function () {
    alert("test");
});
share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

Try removing the LAYOUTS from the ScriptLink

<SharePoint:ScriptLink ID="ScriptLink5" runat="server" Name="SprocketComplete/js/sprocketComplete.js" Localizable="false"/>

Microsoft.SharePoint.WebControls.ScriptLink+ScriptLinkInfo has

public string ToScriptUrl(Page page)

Which does

return SPHttpUtility.UrlPathEncode(SPUtility.MakeBrowserCacheSafeLayoutsUrl(filename, this.Localizable), true);

So the base url is /_layouts/

share|improve this answer
    
No more error, but nothing happens either. See update 2 in my original question to see the Javascript that should be executed. –  Abe Miessler Apr 12 '11 at 4:09
    
Scratch that, it looks like jQuery isn't loading for some reason. Any suggestions for why that wouldn't be loading? –  Abe Miessler Apr 12 '11 at 4:15
    
try adding 'alert("loaded SprocketComplete");' at the start of the js file, it might be that jquery has not loaded yet (see your other question i answered) –  djeeg Apr 12 '11 at 4:16
    
i dont think you want the Defer="true" flag set –  djeeg Apr 12 '11 at 4:16
1  
and the jquery.js must be above the SprocketComplete.js –  djeeg Apr 12 '11 at 4:18
show 1 more comment

First of all I am assuming a full-trust solution since you are deploying script files into the layouts folder.

First word of advice. Configuring 'Copy Always' does not do anything for you since that would copy the file into the BIN/DEBUG folder of your project. Not what you are looking for.

What should work for you is to add your js file to a subfolder in layouts and configure your ScriptLink control as follows

SharePoint:ScriptLink runat="server" Name="SharePointProject1/Demo.js" Localizable="false"

share|improve this answer
    
Are you saying copy the js file to the subfolder in layouts on the file system or in my project? –  Abe Miessler Apr 12 '11 at 18:57
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.