Solution for: Page.IsValid cannot be called before validation has taken place
I am using a wizard control in which I have a next button that has causes validation = true. I also have a checkbox that when changed, in the event handler, I set causes validation = false for the next button. When that button is clicked - I get the following:
Page.IsValid cannot be called before validation has taken place. It should be queried in the event handler for a control that has CausesValidation.
Here is the code:
protected void chk_CheckChanged(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
ImageButton ibtnStepNext = (ImageButton)(this.WizardSummaryTemplate.CustomNavigationTemplateContainer.FindControl("StepNextButton"));
开发者_运维问答 ibtnStepNext.CausesValidation = (!chk.Checked);
}
What would be the recommended solution to disabling validation for the next button so I don't see this error?
My work around was to change the validation group for the button and it worked as expected.
精彩评论