During the early stages of a dev cycle, it's a bit annoying to have all the validation controls enforcing their rules if we just want to move quickly from form to form.
What is the simplest way to disable all the validator controls on a page?
During the early stages of a dev cycle, it's a bit annoying to have all the validation controls enforcing their rules if we just want to move quickly from form to form.
What is the simplest way to disable all the validator controls on a page?
If you're allowed to input garbage data, might it be easier to put in a quick hack to let you just skip forward to the page you wanted to be on in the first place, instead of fiddling with validation?
Set up a javascript to get all the validator controls in your page and set their value to false in a for loop, something like this would work
function DisablePageValidators()
{
if ((typeof(Page_Validators) != "undefined") && (Page_Validators != null))
{
var i;
for (i = 0; i < Page_Validators.length; i++) {
ValidatorEnable(Page_Validators[i], false);
}
}
}
Your best bet is to recursively loop through all controls on the page, looking for all controls that inherit from the BaseValidator class, and then set their Enabled
property to False
. You could write this as a simple library method.