SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 add a verb (link in the top left menu of a web part) to all the web parts in Sharepoint 2010. Is there a way to inject javascript into a all the pages from a custom feature?

share|improve this question
up vote 2 down vote accepted

You can write a custom control that uses the SharePoint scriptlink control and furthers registers your JS file using the ScriptLink.Register method on the page.

Next you can deploy this custom control as a delegate control. You can use any existing delegate control like AdditionalPageHead inside the master page or create a new one.

share|improve this answer

somehow injecting javascript into all the pages just sounds like a bad idea, you could however alter the master page to include a javascript file and deploy the updated master page as part of the feature.

share|improve this answer
This sounds good, but what if the user has customized his master page already? I will overwrite it. – omar Oct 12 '10 at 16:13

Do you really need to add your action as a webpart verb?

Is Ribbon UI or a Site Action acceptable?

How to: Modify the User Interface Using Custom Actions

This series of articles goes into more depth.

Customizing Ribbon UI - Part 1

share|improve this answer
This new verb will perform and action based on the content of the web part. So, I need a way to know which web part the user wants to perform this action on. I think I can use a ribbon button or site action as long as there is a way of knowing the specific web part. – omar Oct 12 '10 at 17:58
Ribbon UI can interact with the currently selected webpart. – Steve P Oct 13 '10 at 13:14

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.