Monday, 21 February 2011

Using ~SiteCollection prefix for referring javascript files

Recently I faced a javascript reference issue in my application. I had javascript file referenced in my master page. I had given relative path to the JavaScript files.

<span style="font-weight:bold;"><script type="text/javascript" src= "../../Script%20Library/jquery-1.4.2.min.js"></script></span>

It was not working for all the pages across application due to different hierarchy.
So below dynamic reference style can be used to overcome this issue.

<script type="text/javascript" src= "<asp:Literal runat='server' Text='<%$SPUrl:~sitecollection/Script%20Library/jquery-1.4.2.min.js%>'/>"></script></span>

Query List/Document Library in Specific Folder

To query SharePoint List or Document Library in specific Folder “ FolderServerRelativeUrl ” as part of the CAML Query Code Snippet ...