Thursday, May 26, 2011

"You must specify a value for this required field” error in custom master page SP 2010

When customizing SharePoint 2010 MasterPages you often don’t want certain content placeholders to show up on the page. You should not delete or comment these elements out but instead set the visible=”false” attribute on the content placeholder. Upon creating a custom MasterPage tonight I found that most of the placeholders hide just fine with the visible=”false” setting; however, I have found a bad side effect of one of them.

If you set the PlaceHolderPageTitleInTitleArea’s content placeholder to visible=”false” within the MasterPage it will save just fine and also render as expected. The problem presents itself when you edit a page that is using this MasterPage. Upon saving the page back to SharePoint you will receive an error stating “You must specify a value for this required field” and the save will fail.

The alternate way to hide this content placeholder is to create a simple CSS class containing “visibility:hidden” and referencing this class with the CssClass attribute of a new asp:panel element that contains your content placeholder. You can hide the others in the same way as well and if you want to hide a whole group of them this may be a good way to get them all in one sweep.

Create a simple CSS class as shown below:
.hiddenpanel
{
visibility:hidden;
}


Use it to on an asp:panel to hide your content placeholder(s):




Other content placeholder's in the v4.master MasterPage to be aware of:
PlaceHolderPageTitle
PlaceHolderAdditionalPageHead
PlaceHolderBodyAreaClass
PlaceHolderTitleAreaClass
PlaceHolderGlobalNavigation
PlaceHolderTitleBreadcrumb
PlaceHolderGlobalNavigationSiteMap
PlaceHolderSiteName
PlaceHolderPageTitleInTitleArea
PlaceHolderPageDescription
PlaceHolderSearchArea
PlaceHolderTopNavBar
PlaceHolderHorizontalNav
PlaceHolderLeftNavBarDataSource
PlaceHolderCalendarNavigator
PlaceHolderLeftActions
PlaceHolderLeftNavBarTop
PlaceHolderLeftNavBar
PlaceHolderQuickLaunchTop
PlaceHolderQuickLaunchBottom
PlaceHolderQuickLaunchBottomV3
PlaceHolderQuickLaunchBottomV4
PlaceHolderPageImage
PlaceHolderTitleLeftBorder
PlaceHolderMiniConsole
PlaceHolderTitleRightMargin
PlaceHolderTitleAreaSeparator
PlaceHolderNavSpacer
PlaceHolderLeftNavBarBorder
PlaceHolderBodyLeftBorder
PlaceHolderMain
PlaceHolderBodyRightMargin
PlaceHolderFormDigest
PlaceHolderUtilityContent
SPNavigation
WSSDesignConsole

No comments: