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.