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

posted @ Thursday, March 27, 2008 2:34 AM

Print

Comments on this entry:

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

Left by Jason at 4/4/2008 6:37 AM
Gravatar
Hey Rob,
Thanks for the post that one has been bugging me for a bit now. One problem, when I made the change to the .js file the bug still exists. Is there something else I missed?

Thanks
Jason

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

Left by StefanM at 8/26/2008 12:12 PM
Gravatar
Thanks for solving this. I have a tip if this fix hasnt been included in the control toolkit yet. Ive also experienced this bug earlier and just setting SetFocusOnError to true for the validator controls served as a workaround for me.

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

Left by Srimal at 10/27/2008 1:54 PM
Gravatar
Thanks... I was looking for this... i used your steps to overcome the bug... thanks a lot....

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

Left by Daryl van Sittert at 1/20/2009 4:22 AM
Gravatar
Thanks

SetFocusOnError="true" was a simpler solution for me which worked.

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

Left by rob at 1/23/2009 12:11 AM
Gravatar
Daryl, you're right. They've since included my patch in the control toolkit source, so this hack should no longer be needed.

Your comment:



 (will not be displayed)


 
 
 
Please add 6 and 6 and type the answer here:
 

Live Comment Preview: