views:

79

answers:

3

I am doing some work on a legacy project, one that has been upgraded through the years from 1.1, to 2.0, and is now set at 3.5. Currently I am having some issues with required field validators not running when I click submit.

It's a pretty simple setup. I have two textboxes, I need both to be filled when a user clicks submit, I have RFV's pointing to each textbox but when I click the submit button the validation is not fired and then the resulting code bombs out. I have tried using both ValidationGroup on the relevant controls and also changing Display from "Dynamic" to "Static", with no results.

I've also had some issues when using AJAX controls where I get javascript errors and the like, which to me would point to an incorrect config regarding client-side libraries. Of course, I'm not really sure how to go about pinpointing the errors in my config. Any suggestions?

Thanks,

Mike

A: 

If you are receiving javascript errors, than that would be why your validation controls aren't firing.

Try using a tool called FireBug to pinpoint where your javascript errors are arising from.

Jack Marchetti
I'm not actually getting Javascript errors in this particular case, but I have with some of the other client-side controls I would use which suggests to me that my client-side setup isn't exactly working properly. When I do get these errors it's usually somewhere deep inside a ScriptResource.axd?id=a121939d type script with some error like "Sys.Webforms Is Undefined" or "Object Expected" or some otherwise difficult to diagnose issue. Again, these aren't actually occuring in this particular case.
Mike C
+1  A: 

As for the specific error, I am not sure, but I would caution you to modify your code to ensure that you do not have problems on the server side.

Add a check in your method to ensure that the validators are valid.

if(Page.IsValid)
{
    //Now do your thing
}
Mitchel Sellers
I just happened to make a related comment above at about the same time :). When I add some code server side to check manually, then the validators will work (after postback, not client-side). When I remove it they break.
Mike C
A: 

I found the solution while researching a similar problem on Telerik's support forum. The trick is to remove the tag <xhtmlConformance mode="Legacy"/> from the web.config as this somehow prevents the proper JS libraries from being loaded into the page.

Mike C