Insert a custom webpart in Master page

For an Intranet SharePoint site, I had a requirement to insert a custom Search web part on the Master page, just below the Quick launch section.

Insert a custom webpart in Master page

But we can’t add a web part zone into the Master page, So I used this trick. In master page, there is a content placeholder: <asp:ContentPlaceHolder id=”PlaceHolderLeftActions ” runat=”server”></asp:ContentPlaceHolder>, So I placed the SAME ID for my web part zone in the Page layout/Page, So that in run time, The Master Page’s content on PlaceHolderLeftActions will be replaced by the content page.

<asp:Content ContentPlaceHolderId=”PlaceHolderLeftActions” runat=”server”>
<WebPartPages:WebPartZone id=”g_A66B59618EF44FE89FCE36DA164B9CC5″ runat=”server” title=”Zone 1″>

In simple steps:
1. Create a Blank .Aspx page with SPD
2. Just insert the code as per the below screenshot

<asp:ContentPlaceHolder id=”PlaceHolderLeftActions ” runat=”server”></asp:ContentPlaceHolder>

3. Now attach the master page, and then insert the desired web part.

Same way, If you want to insert a webpart in Master page, you can use the same Technique, insert your own Tag in Master page and replace the content in your content page by assigning the same tag.
<asp:ContentPlaceHolder id=”MyTag” runat=”server”></asp:ContentPlaceHolder>

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “Insert a custom webpart in Master page

  • when iam placing tag i got error


Leave a Reply

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