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

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.

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
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 '13 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:

share|improve this answer

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

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.