Monday, November 17, 2008

Validators on update panel not working properly

The problem is occurred seriously on window 2003. Error messages of validators is not displayed properly.

-Simulate the problems:

1. Create a sample ajax application.
2. Drag a textbox, a requirefieldvalidator and a button to an update panel.
3. Deploy it to web server running window 2003.
4. Leave the value in the textbox empty, then click submit button. It work fine in this stage.
5 Enter some text and click submit. At this time, server is doing asynchronous post back to the server. Finally try to leave the value empty again and click submit. You will not see the error message of validator controls.

- Solution:
1. There is a work around to solve this problem by setting EnableClientScript = False of every validator controls under update panel. This will disable client validatation, so instead we need to do validation on server.

{ //do actioin

2. Another solution from Matt Gibbs's blog:

It works fine most of the case,but it has a problem when setting "DisplayMode" of validation controls to "Dynamic". Validation is not fired unless the page submit two times.

No comments: