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 developing a custom webpart and I'd like to leverage jQuery for some of my client side functionality. I found a few articles that lay out the following technique for adding a script reference to a page from a custom webpart.

In my CreateChildControls method I added this line:

ScriptLink.Register(this.Page, "/_layouts/1033/jquery.js", false);

Then ensured that the script file is being deployed as part of my feature.

But after following this example I get the following error:

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

I can take that path string and throw it in the address bar after "http://%servername%" and the browser tries to download the script file so it's obviously there. What am I missing here?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

this.Page.ClientScript.RegisterClientScriptInclude(this.Page, this.GetType(), insertuniquekeyhere, "/_layouts/1033/jquery.js");

See the RegisterClientScriptInclude page on MSDN for details. Other ScriptManager methods might also help.

share|improve this answer
    
Sorry it took so long to mark as answer I was on another project for a bit. –  jjr2527 Jan 21 '11 at 6:44
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.