I ran into a really bizarre error today. We've created a custom page layout which sub classes PublishingLayoutPage to provide a custom contact us form with some basic validation controls. Everything works fine until we add the RegularExpressionValidator control. Once we do, we get this error: RegularExpressionValidator is not allowed on this page or could not be found or it is not registered as safe. The things that I have verified.

  • RegularExpressionValidator is registered as safe in web.config
  • Our custom page layout code behind class is registered as safe in web.config
  • The form works fine in a stand alone asp.net application
  • Other validator controls in the same MS namespace work fine e.g. requiredvalidatorcontrol

This issue seems to be unique to SP2013 because I've done this sort of thing before with no issues. I would like to know why this one control will not work in this scenario.


In turns out that the best practices solution is to move whatever custom code you have into a user control that lives in the CONTROLTEMPLATES directory, and then reference the control from the layout page. ASP.Net code in this directory has no limitations or oddball behaviors, and is the more secure and safe way of achieving this. Don't bother with updating MOSS web.configs to accommodate additional page parsing paths just create a user control deployed via solution and be done with it. Hopefully this will save someone else some time.


The RegularExpressionValidator is explicitly declared as Safe="False" in my SharePoint 2013 environment but I have no idea why it is configured like this.

As a workaround, one can use the InputFormRegularExpressionValidator from SharePoint assembly InputFormRegularExpressionValidator on MSDN

  • I undeleted your previous answer, please use that one :) Nov 26 '13 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.