Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

(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?

Debug.Print(this.Page.ClientScript.IsClientScriptIncludeRegistered("foo"));

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

2 Answers 2

  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
1  
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

 
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.