Hi there,
I have a form that requires the user to enter two dates where the first must
be before the second. I only want to validate the dates when the user clicks
the OK button.
I've tried using the validating events but the best I was able to accomplish
was to have the validating event fire for the group box that contains the
date entry controls. The problem that occurs then is that the event fires
because the user clicked on the OK button. That seems to cancel out the OK
click and you have to click OK again.
I then tried to do the validation during the OK button clicked event.
Unfortunately, I can't figure out how to cancel the click event if there is a
problem with the date. I'm able to pop up an error message, but then it just
continues to close down the form and return to the calling form. Is there a
clean way to do it?
Thanks,
Carlo.
Sijin Joseph - 14 Oct 2004 05:00 GMT
are you setting CancelEventArgs.Cancel = true in case validation is failing.
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> Hi there,
>
[quoted text clipped - 17 lines]
>
> Carlo.
carlor - 14 Oct 2004 14:15 GMT
Yes, I was setting it to true.
Carlo.
> are you setting CancelEventArgs.Cancel = true in case validation is failing.
>
[quoted text clipped - 23 lines]
> >
> > Carlo.
Claes Bergefall - 14 Oct 2004 08:32 GMT
Don't set the AcceptButton property on your form
In your click event handler call Close if everything is valid
/claes
> Hi there,
>
[quoted text clipped - 17 lines]
>
> Carlo.