Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validator prevents user from cancelling out of screen 3

Status
Not open for further replies.

RebLazer

Programmer
Jun 7, 2002
438
US
I have a page with a validator and a "cancel" button. When the user enters an invalid entry, the validator is displayed (that's good). The problem is that the validator prevents all postbacks - including functionality of my cancel button. So if the user enters invalid data, the validator won't let the user click the cancel button - instead it holds the user in place until the user corrects the input.

Whereas I don't want the rest of my buttons on the page to work while the validator is in the "invalid" state, I do want to keep my cancel button functional (i.e. allowing it specifically to do a postback).

How can I do this?

Thanks so much,
Lazer [rainbow]
 
Any help would be greatly appreciated!

Thanks,
Lazer
 
The only thing I can think of right now that might work is to use a link instead. Either text, or an image that says cancel. Maybe have it redirect them to the home page.
 
Set the CausesValidation property to False on the Cancel button.
 
The problem RealQuiet is that the validation occurs before the click event of the cancel button.
What I tried doing was writing a CustomValidator.
The CustomValidator doesnt prevent any postbacks, but you can test the isValid property before you do the postback.

Phil
_____________________________________________________
We are drowning in data, but starved for information.
 
I have some required field validators as well as Range Validators on a page. The validation doesn't fire on the buttons that have the CausesValidation = False. The postback happens, and everything works fine.
 
I found the cause of the confusion.

If you set the 'CausesValidation = False' in the properties window of the button on the design window it works properly.

If you set the 'CausesValidation = False' in the codebehind it doesn't work properly.

I havent tried setting it in the html, but I imagine it will work properly there too.

Phil
______________________________________________________
We are drowning in data, but starving for information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top