How to properly hide ContentPlaceHolders in your SharePoint 2010 Master Page

Recently I had a friend ask me to help him with an issue on a page layout they were having.  When he opened the page in SharePoint designer and went to edit the page layout, he saw this message.

The first thing I did was have him search the master page for TitleInTitleArea, since that did not show any results I assumed the ContentPlaceHolder was missing.

I had him add an ASP:Panel to the bottom of his master page and add the missing ContentPlaceHolder there.

ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" Visible="false" />

Once that was done he no longer had the error on his PageLayout and the issue was fixed.

I quickly received another ping. His page was now broken.

I knew from this error that there were duplicate place holders on his page, so I had him go back and remove the placeholder we just added and recheck his page layout.  His page layout was still showing the same error.

Once we started a sharing session and I was able to view his master page and found the issue.

The person who created the master page had commented out the placeholders.

Once the ContentPLaceHolders that were commented out were moved into an ASP:Panel that was hidden the page layout was no longer broken and there were no more errors.

Lesson: Don’t comment out your ContentPlaceHolder. Move the ones you are not going to use into an ASP:Panel with the visibility set to false.

Here is a screen shot of my asp:panel on a recent custom master page.

Update Note: There is a ContentPlaceHolder that you do not want to add to the hidden panel. Please read this post.

, , , , ,