Saturday, January 15, 2011

Insert a custom webpart in Master page

For a Intranet SharePoint site, I had a requirement to insert a custom Search we bpart  in Master page, just below Quick launch section.

Insert a custom webpart in Master page

But we can’t add a webpart zone into Master page, So I used this trick. In master page, there is a content place holder: <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 webpart.

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 same tag.
<asp:ContentPlaceHolder id="MyTag" runat="server"></asp:ContentPlaceHolder>

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

1 comment :

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...