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

I have to add a custom webpart to master page programmatically. I tried to go common way using:

web.GetLimitedWebPartManager("/_catalog/masterpages/default.master", PersonalizationScope.Shared)

but it says that the URL in incorrect. I have also tried url like

web.Url + "/" + web.MasterUrl

but it still doesn't work. If works perfectly with default.aspx (but webpart is shown only on the homepage not in all pages and it's clear why), so I suppose the problem is that the page has '.master' extension.

What is a correct way to add webpart to master page? I need this webpart to be located on every site page, not only on the homepage.

Thx in advance

share|improve this question
add comment

1 Answer

As per MSDN: You cannot add Web Parts in zones to a master page. You can add static Web Parts (parts outside of a zone) to a master page, but you cannot add dynamic Web Parts to master pages. The better way to do this is 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
add comment

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.