I added user control and then empty module to reference user control inside SharePoint 2013 master page but it is not working.

Control Id="AdditionalPageHead" Sequence="150" ControlSrc="~/_CONTROLTEMPLATES/UsageReport/SiteUsageActions.ascx">

I want a add javascript in the Masterpage and deploy it as a feature. How to achieve this?

  • 1
    I want a add a javascript in masterpage using a solution and feature, how to do that. Jul 27, 2015 at 9:23

3 Answers 3


In order to include javascript in masterpage, using the code given below:

<SharePoint:Scriptlink ID="Scriptlink120" runat="server" name="~SiteCollection/Style Library/JS Path" language="javascript" />.

Add this in your master page and then deploy the solution. This shall include the JS file globally which will allow you to use it at all places.

  • 1
    Mancy, i understand by giving reference in master page i can do that but i don't want to edit my master page file. Jul 27, 2015 at 9:28
  • If you do not want to edit your master page, then you would need to include the javascript using the <script> in each and every place that you are using the JS. This is not a good alternative, so I suggest that you should include it once in the master page. Jul 27, 2015 at 9:31
  • Mancy, there is a method Using Delegate Control through Feature we can achieve this. And that's what i am trying to implement but no luck :( link spdeveloper.co.in/tipsntricks/pages/…) Jul 27, 2015 at 9:34
  • Please post the error that you get. And try referring this - blogs.msdn.com/b/kaevans/archive/2011/04/06/… Jul 27, 2015 at 9:35
  • nothing happens, no error and i don't get my alert. Jul 27, 2015 at 9:37

The best options to inject JavaScript in a SPWeb when activating a feature are:

  • i want to add JS Using Delegate Control through Feature. Jul 27, 2015 at 9:32

I was adding wrong control source path,

Control Id="AdditionalPageHead" Sequence="150" ControlSrc="~/_CONTROLTEMPLATES/UsageReport/SiteUsageActions.ascx"

just added /_CONTROLTEMPLATES/15/ solved my problem.

Control Id="AdditionalPageHead" Sequence="150" ControlSrc="~/_CONTROLTEMPLATES/15/UsageReport/SiteUsageActions.ascx">

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.