using System.Web.UI.WebControls;
//if we are not in display mode disable all the validation controls to make sure saving the page the webpart is on works. if (WebPartManager.DisplayMode != WebPartManager.BrowseDisplayMode) { foreach (var validator in Controls) { if (validator is BaseValidator) { ((BaseValidator)validator).Enabled = false; } } }