SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

(a) Is there a mechanism (by sharepoint) of registering to include a script into the aspx page?

(b) If yes, then if I do the following from a user control what would be the result?


Assume that foo is the name of script-include which I have somehow registed by some sharepoint mechanism [i.e. (a)]

share|improve this question
  1. You could simply use a <ScriptLink> element in your web part here.

  2. You can create a control and deploy it in a feature so that the script is on all pages and available for you example.

  3. You could simply add the script to your web part link you would any other javascript.

To add in Hugh Wood's point. The Control Template (2nd option) is the better option.

share|improve this answer
A control template is the better two of the options, you don't need the designer gubbins, but it more manageable. – Hugh Wood Nov 19 '12 at 15:06

You can try embeding your js into the dll and register it from the oninit. The downside is that if you need to make a change in your js file, you'll need to redeploy de dll into the gac Here's how

share|improve this answer

Your Answer


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.