Add WebPart to your master page?

We know that webparts in the master page are not configurable, unless you configure them in SharePoint designer. If you edit the page, it won’t be editable. and we hear about putting a webpart inside the master page so it appears everywhere. Or maybe your manager told you to put the webpart inside of each page layout that’s developed by another developer. But how to achieve this?

Let’s first add our custom webpart to a webpart page stored in the pages library (or any other library but it makes sense to put it in pages library).  Name it fortest (name doesn’t matter because you won’t be using it anymore after you finish this process).

Now you have a webpart page, add your custom webpart to this page.

Now you’ll have to play with SharePoint designer to put this webpart inside your master page.

Open up SharePoint designer, and navigate to your webpart page. You can see it by clicking All files from the left pane, then you’ll find your pages library in the right pane, click it and then double click on the fortest.aspx to edit the page. It will display something like this:

 

You’ll find a registry entry at the beginning of your code, copy it and save it in a text editor. Then scroll down to your webpar, it will be something beginning with <WpNs0:Testwebpart runat=”server” ID=”

Copy it and save it in the text editor.

Now delete the webpart page, we don’t need it anymore. And open your master page. At the beginning of the master page, paste the registry entry that you copied from your webpart page below the other registry entries. now we’re done from the first part. To the second part, paste what you copied from the webpart page which represents the webpart itself which begins with  <WpNs0:Testwebpart runat=”server” ID=”… at whatever place you want it to  appear inside your master page. You can paste it below the footer or wherever you want.

To sum it up: you need to add your webpart to a webpart page, and then copy 2 entries from it, the registry entry which registers the webpart in the page, and the webpart entry itself.

5 thoughts on “Add WebPart to your master page?

  1. I don’t understand how I should find the fortest.aspx and where you should create that site. All I understood was that I should rename the webpart when I had added it to the SP-page.
    Can you pleas describe more?

    1. Thanks Malin for your response,

      You create the test page manually, you can do so in SharePoint Designer, and you can do so in the same site that you are working on. To do so, open SharePoint Designer, open the site that you are working on, and from the main menu click Add Web Part Page, name it testpage or ToBeDeleted, this will give you the same user interface as the one in the original post, then follow the same steps in the post.

  2. Oh my goodness! Awesome article dude! Thanks, However I am encountering difficulties with your RSS.
    I don’t know the reason why I can’t subscribe to it. Is there anyone else having similar
    RSS problems? Anyone that knows the answer will you kindly respond?

    Thanx!!

Leave a Reply

Your email address will not be published. Required fields are marked *