Message Box Works with Validators

  • Thread starter Thread starter cksj
  • Start date Start date
C

cksj

I have a button that will trigger validators. In one special case, I have to
show a message box when the button is clicked.
In the code behind, I added the following:

cmdAccept.Attributes.Add("onclick", "javascript:checkPayment();")

The message box will not show because of the validators. It will only show
if I set CausesValidation=False on the the button. Is it possible to have
validators on the button as well as pop-up a message box on certain
situations?

thanks,

Cesar
 
When you have the button cause validation, how the framework does that is to
call a JavaScript to validate, and then the JavaScript submits the form. So,
it has already injected an onClick event handler, and now you are injecting
a second one, which is summarily ignored because you only get one handler
per event. In order to get both, set up one with validation, and then copy
the event handler method that is injected. Then, take validation off, run
your script, and call the validation function on the appropriate code path.
 
Back
Top