This blog has moved to www.sharepointconfig.com

Sep23

ASP.NET validation controls prevent publishing pages from saving

Categories: Errors, Web Content Management
The situation
 
You have an ASP.NET control that contains validation controls in the masterpage or page layout for a publishing site (an ASP.NET login control for example). When you try to edit and check in a publishing page you receive the following error.

This page contains content or formatting that is not valid. You can find more information in the affected sections.
 
The problem

Even if you fill in all the required fields on the publishing page, the validation controls on the other ASP.NET controls prevent the page from saving.

The solution
 
One quick way of rectifying this problem is to place an EditModePanel with PageDisplayMode=”Display” around the controls to prevent them from displaying when the page is in edit mode. For example:

<PublishingWebControls:EditModePanel runat=server id="EditModePanel1" PageDisplayMode="Display">
    <asp:Login runat="server" id="Login1"></asp:Login>
</PublishingWebControls:EditModePanel>

This will only render the control when the page is in ‘Display’ mode so validation will not occur when users are editing the publishing page.
 
 

Comments

On 20 Feb 2009 10:56, Brad said:

Thanks for publishing this; it was exactly what I was looking for.

On 02 Apr 2009 12:11, Prince K said:

Thanks alot .. :)

On 02 Oct 2009 05:13, Tom Resing said:

This post came in very helpful to me today. Thanks, Ari!

On 15 Oct 2009 05:41, Ari said:

This blog has been moved to SharePoint Config. To view or comment on this article please head over to ASP.NET validation controls prevent publishing pages from saving.

Comments for this article are now closed.