Ben Fulton
Ben Fulton

Reputation: 3998

Two ModalPopupExtenders on a page cause incorrect validation issues

I have one aspx page that has two UserControls on it; each is primarily a ModalPopupExtender. One has validators; one does not. The one that does not has a Submit button with the CausesValidation="false" attribute on it.

When that Submit button is clicked, nothing happens. Click it again, and the postback happens as expected. There is clearly some validation issue going on here, because if I remove all validators from the page, the postback succeeds on the first click.

What's going on here?

Upvotes: 1

Views: 1129

Answers (3)

BenB
BenB

Reputation: 10630

Have you tried removing the OK button property from the modal popup?

Upvotes: 0

Ben Fulton
Ben Fulton

Reputation: 3998

Make sure that the buttons that show the ModalPopups are marked CausesValidation=false as well. What was happening was that the "Show Dialog" button for the non-validating dialog was not marked this way; this was causing the entire page to validate when that dialog was shown - including the other dialog, which did have validation and was failing it. This caused the Submit button to fail for apparently no reason.

Moral of the story: Make sure to use CausesValidation on any buttons that don't require it, and use Validation Groups to separate out various page parts, especially when parts of the page are not visible.

Upvotes: 0

RSolberg
RSolberg

Reputation: 26972

Without seeing the code, I can't say this for certain, but it sounds like you may need to utilize the validation groups. The validation group would be set on the validation components as well as the button that posts back the page.

Upvotes: 1

Related Questions