Validator Callout doesn't display on second control after fixing first control

There’s a bug in the Validator Callout in the AJAX Control Toolkit documented by bugs 10900, 12342, 15698, and 11701 on the Code Plex site.  All 4 bugs describe the following undesired behavior:

  1. Pull up the AJAX Control Toolkit Sample site’s Validator Callout example (here)
  2. Push submit
  3. Note that both fields are invalid, and the first field shows the Validator Callout
  4. Add text to the first TextBox
  5. Push submit
  6. The Validator Callout for the top text field is gone, the Validator Callout for the second TextBox is not shown but should be

This is the symptom identified by these 4 bug reports.

The problem?  The Validator Callout set this._isOpen at the top of the show() method, but actually did the showing at the bottom of the method – after checking a few more things.  So, when you push submit in step 2 above, it actually sets this._isOpen = true on both Validator Callouts even though only one is actually visible.  Once you fix TextBox 1, and push submit, it runs through the validators again, notes #1 is now valid, and #2 is still invalid.  It also notes that #2 says it’s visible, and doesn’t bother showing it.

The solution is uber-simple:

– Replace the get_isOpen() function at the bottom of ValidatorCalloutBehavior.js with this one, which actually checks if the pop-up is visible:

  get_isOpen : function() {
    return $common.getVisible(this._popupTable);
  }

– Delete all lines that assign something to this._isOpen (e.g. this._isOpen = false;)

– Replace all lines that use this._isOpen with this.get_isOpen().  By my count, there are two such lines: one in show() and one in hide().

That’s it.  It now no longer guesses if the validator is visible, it checks the table it created to see if it’s actually visible.

I’ve submitted the patch to the 4 bugs on CodePlex, and hopefully it’ll get into the next release.  If you’re anxious to have this bug fixed as much as I, you can just download the modified file from CodePlex here including the JavaScript unit test that proves the problem existed and is now solved.

Rob