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 in SharePoint 2010 Designer to create a custom page layout. I've added a SharePointWebControls:ScriptLink control but am not sure what the path is to my jQuery library. It's uploaded to the root collection's Site Assets, in subfolders /js/jquery/jquery-1.6.2.min.js.

The absolute URL to it is http://vmdev195/SiteAssets/js/jquery/jquery-1.6.2.min.js. Is there a way to give a relative path to this file in the ScriptLink control? This way the page will work on different servers that have the same folder/file structure. Thanks

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

If you're working in SharePoint Designer, then you can use a plain old tag instead and reference the .js file anywhere you want:

<script language="javascript" type="text/javascript" src="/Scripts/jquery.SPServices-0.6.2.min.js"></script>

Any relative path will work, whether it's in _layouts, a Document Library, or an external CDN.

share|improve this answer
    
Thanks, Marc. That worked beautifully :) For some reason, I forgot that the client-side options are available in asp:Content areas. Plus, Designer allows you to pick the file and it'll generate the path automatically. Very nice. –  Alex C Aug 4 '11 at 14:18
add comment

Have you tried this?

<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<!-- ... -->

<SharePoint:ScriptLink runat="server" Name="/SiteAssets/js/jquery/jquery-1.6.2.min.js" Localizable="false" />
share|improve this answer
    
Thanks, omlin. I've seen the SharePoint:ScriptLink tag but couldn't figure out what the difference is between that and the SharePointWebControls:ScriptLink tag. –  Alex C Aug 4 '11 at 10:27
    
That doesn't work; it throws this error, even though the file is there: Cannot make a cache safe URL for "1033//siteassets/global/js/jquery/jquery-1.6.2.min.js", file not found. Please verify that the file exists under the layouts directory. What does work is this: sensoft2000-sharepoint.blogspot.com/2009/09/…. Not the most convenient way to do it, but it works. –  Alex C Aug 4 '11 at 10:50
1  
Alex, I'm afraid you simply forget about Localizable="false" attribute.. That's why you're getting "1033" attached in front of the url. –  Andrey Markeev Aug 5 '11 at 7:43
    
Thanks, omlin. Very helpful tip. –  Alex C Aug 6 '11 at 5:37
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.