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?

1 Answer 1

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.

  • Sorry it took so long to mark as answer I was on another project for a bit.
    – jjr2527
    Jan 21, 2011 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.