Validating a text box and a cancel button

C

Chris Dunaway

I have a form with a textbox on it. The textbox will contain a user
entered id number. Since I want the ID number to be unique, I have added a
validating event handler to check that the user id entered is not already
in the collection. If it is, I indicate an error to the user and set the
cancel property of the validating event to True so the user will enter the
id again.

I also have a cancel button on the form. If the user has entered an
incorrect value in the textbox and then clicks cancel, I don't care about
the validation.

But, when the user clicks the button, it still indicates that the entered
user ID is invalid. I want, that if they click cancel, to ignore the
validation of the textbox. To do this, I set the CausesValidation propert
of the *cancel button* to false, thinking that when clicked the form would
not be validated, but it has not worked.

Any suggestions?

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
C

Chris Dunaway

Solved my own problem. The Cancel button was on a panel whereas the
textbox was not. It was the panel that was causing the validation. I set
the panel's CausesValidation property to false and that solved the problem.

Thanks

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top