ASP.NET Validators Do Not Fire in Firefox

I recently had to make some upgrades to an application that was built using the .NET 1.1 framework. Just to add a bit of background to this post, I am currently using Visual Studio 2008 on my laptop and was able to successfully perform a migration of the solution from .NET 1.1 to 2.0.

When I attempted to test my ASP.NET validators, I realized that they were not working properly in Firefox. By properply, I mean, they weren’t firing at all. I did a bit of research and found that back in the .NET 1.1 days, the javascript that the validators outputted used a proprietary document.all() syntax which was not understood by non-IE browsers. The supported syntax is document.getElementByID().

In .NET 2.0, this was apparently fixed. However, even though I had converted my project successfully, I still couldn’t get the validators to fire. I did a small test where I created a new .NET 2.0 application, added some validators, and ran the application in Firefox and I found that the validators did work. So it had to be a setting in my project that was not modified during conversion.

Turns out, within my web.config, I had to change the following line of code from:

1
<xhtmlConformance mode="Legacy"/></system.web>

to

1
<xhtmlConformance mode="Transitional"/></system.web>

That resolved my issue.

4 Responses to “ASP.NET Validators Do Not Fire in Firefox”

  1. Tom von Alten December 8, 2008 at 6:14 pm #

    Thanks for this post. I had the inverse problem: having developed with Firefox’s behavior, I was getting what I wanted with ValidateRequest=”false” set for the page, and controlling what, and when I validate with my codebehind. Come to find out IE fires the validators no matter what, breaking the form’s [CANCEL] button. One has to satisfy all the form validators before the inputs can be discarded? This is not intelligent behavior. As you found, by changing the Web.config xhtmlConformanceMode setting, I could get the same behavior from both Fx and IE. Unfortunately it’s the same WRONG behavior. :-( So… how do we tell IE that thankyouverymuch, but we do NOT it to fire validators unless commanded?

  2. Tom von Alten December 8, 2008 at 6:14 pm #

    Found the answer: add the attribute CausesValidation=”false” to the control(s) in question.

  3. shereen December 8, 2008 at 6:14 pm #

    @tom: thanks for the comments. That makes absolutely no sense that you’d have to satisfy all form validators before IE will permit you to reset your form. Interesting scenario. Changing the xhtmlConformanceMode setting effectively resulted in the same behavior for both of us: consistency from both browsers. However, as you pointed out, that doesn’t necessarily mean we get the CORRECT behavior. Thanks for posting your answer, hopefully someone else will find it useful!

  4. Mark December 8, 2008 at 6:15 pm #

    Thanks for this post. I was working on a asp.net website someone else had built and this error was driving me nuts. Thank goodness for Google and kind people like you who post their solutions.

Leave a Reply