I want to have a feature which causes the following to happen everytime any page in a site loads.

I need to have a web part or user control which adds information about the current user to the page. This information doesn't need to be displayed to the user, it just needs to be available for javascript to read it. It can be either in meta tags or as a script block.

The feature uses a custom action to reference a javascript file which uses the information set above.

The issues I'm running into are:

  1. How can I ensure this user control is on every page? I can manually add the web part to the master page but what about pages using other master pages? It also seems that it is best practice to avoid modifying master pages if possible.

  2. Timing issues - I'll need to make sure that the information is available on the page before the javascript is added.

I'm still new to SharePoint so any suggestions are highly appreciated.

3 Answers 3


You may perhaps try using Delegate Controls and the AdditionalPageHead delegate control can be the best candidate as it is available in all OOB master pages.

  • Definitively the way to go. I use this technique to inject a control that register all common JavaScript (jQuery, knockout) and Css for a whole web application. A good point of this technique is that you can control the granularity. When you declare your additional delegate control and you add it in a feature, you can specify the scope of the feature (from farm to web)
    – Steve B
    Jan 11, 2013 at 8:59

The only way to fully control the events in a page load is to make sure of a HttpModule. If you dont know much about HttpModules, this is going to be difficult. Anyways, I'd suggest you save the values to your page using a HttpModule. Read more here: http://msdn.microsoft.com/en-us/library/ms227673(v=vs.100).aspx


Javscript Object Modal can be used to fetch profile information of current logged in user more information is here

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.