Problems with Validation Controls in Internet Explorer

Posted on July 04, 2004  |  

Posted in Development

76 comments

We had us a scare at work the other day with validator controls. All of a sudden they seized to work in IE.

As you know, validator controls render client-side script for IE users so no postback occurs in case there's a problem with data entry. Everything happens in JavaScript code written specifically for IE. At some point, "down-level" browsers, aka all non-IE browsers, fell away from Microsoft' grace and became sons of perdition. In down-level browsers no validation scripts are present and you must validate each page via Page.IsValid on postback. If you're curious why this is so read ASP.NET Adaptive Rendering and Validator Controls and A Look at ASP.NET's Adaptive Rendering.

Anyway, the normal behavior of a validator control in IE is to prevent a postback and have an error message displayed. In our case, the script did display an error message but the page still posted back with bad data! A search in newsgroups turned up nothing. I mean, people had this exact issue but the best advice anyone could offer was to check if validation scripts in the aspnet_client folder were there.

We ASP our product, and every other instance of it had validators work perfectly. This one instance was resisting. Just for the heck of it, we made an exact copy of this malfunctioning instance and created a web application in IIS for it. Everything worked for the replica! This weirdness had us scratch our heads.

The solution turned out to be simple enough. Yep, it was one of those, "Oh well, f*** it" solutions. We deleted the bad instance from IIS and re-created it right back. I don't know why it worked, but apparently it was something about the IIS metabase. We worried about an SSL certificate this instance had, but once we recreated it in IIS it was smooth sail. Pages didn't postback with bad data anymore.

If anyone knows how IIS metabase can affect the work of validator controls in IE, please leave a comment. I'm very curious.

76 comments

Ryan Farley
on July 12, 2004

Wow, talk about weird. I was going to be troubleshooting this very problem tomorrow on one of my sites. You just saved me some big headaches. Gotta love syndications, it's like the answers just come and find you ;-)

Anyway, since you've saved me some time, I'll make sure I post back anything I might find as to why this is happening etc.

Thanks again, Milan.

-Ryan


Scott Mitchell
on July 14, 2004

When you examined the code sent to the browser for both versions (the working version and the non-working one), how did the markup differ?


Milan Negovan
on July 14, 2004

The funny thing is the code was identical down to the last byte! This is why we figured we needed to look elsewhere.


srinivas
on August 20, 2004

hai
i have a problem in validation controls in asp.net
when i am uploading my application through FTB server
the validation controls are not working
what is going on pls help me?????????


Milan Negovan
on August 20, 2004

Well, the only advice I can give without seeing your setup is to make sure you also have the "aspnet_client" directory either in web root or in the web app folder. Feel free to also post this question at ASP.NET Forums.


David
on September 20, 2004

If the client side validation controls are written specifically for IE, then why doesn't someone re-write the javascript file for all browsers? The WebUIValidation.js file is not that big, and a good start would be to change all "document.all" functions to "document.GetElementByID". Then wouldn't the client side validation code work for all browsers?


Milan Negovan
on September 20, 2004

As a matter of fact, some people have re-written validator controls to wok in various browsers. There a couple of commercial products of this kind floating around.


David
on September 20, 2004

Yes Milan, I've read about those commercial products too. The problem with most people if those controls are really worth the price. I've just read an article that provides a workaround... It explains what you have to do on the client side javascript and also workaround on the server side (Because the client side javascript even attempt to run if some server side elements are missing)...

http://aspnet.4guysfromrolla.com/articles/051204-1.aspx


RP
on November 23, 2004

Funny, but I had this same problem a week ago.. what I did was I opened IIS, open the properties of the site.. remove the application and create the application. It worked. (Actually, before I came up with this situation, I also browsed through so many "help" sites but to no avail) Just like the article above.. what they are telling is that make sure you have the asp_client folder. It would really be cool if somebody could explain this "phenomenon".. hehehehe.. Nice article. Now I know that Im not alone.


MikeD
on December 1, 2004

I had a similar problem. The cause was the aspnet_client directroy was missing from the site directory. Initially I placed this file in the applications virtual directory... However, that did not resolve the problem. Once I moved it into the site directory, client side validation started working.


Jay
on December 3, 2004

I had the same problem except I had the asp.net client directory but when I went further into it I noticed 2 directories under system web. I deleted the most recent and my validation controls all of a sudden are fine now in IE.

j.


janetk
on January 13, 2005

Thanks for steering me in the right direction here. My localhost validation controls ceased working today seemingly out of the blue. (However I did run the Windows SP2 Update yesterday...) Copying the .js files from my asp_client folder from the root back into my site asp_client folder fixed this immediately. Still would be nice to know what caused this in the first place...


Brian
on February 21, 2005

After migrating from IIS5.0 to IIS6.0, I had a similar problem. All of my client-side validation stopped working properly. Even on a page where all fields were filled in correctly, validation would fail and I wasn't able to submit ANY of my forms. Here's what I did to fix, hoepfully this will help somebody in the future:

1) find aspnet_regiis.exe on your machine
2) open a command prompt and cd to the directory where you found aspnet_regiis.exe above
3) type: aspnet_regiis.exe - ea (this will remove all the client-side validation that IIS has registered for all ASP versions installed)
4) type: aspnet_regiis.exe -c (this will re-install the client-side validation)

This worked for me with about 10seconds worth of work, hopefully someone else may find this useful.


Premjeet
on March 2, 2005

Hi Milan and Ryan, I had the same problem as described here. The validation control are working but it is post back with bad data.
The application is tested locally, using the local IIS and it woks fine. But when it runs at the hosted server, it does not work.
I have gone through the description above. But I could not understand how to go for it. I will be very haapy if you could share how to do this(Deleting bad instance from IIS and re-created it right back). If u would'nt mind, mailing to me will be a very good gesture.

Cheers
Premjeet


Lauren
on March 22, 2005

Brian - thanks so much for that very helpful info. All of my validation works perfectly again now. :)


Gyanesh Mishra
on March 28, 2005

hai
i have a problem in validation controls in asp.net
when i am uploading my application through FTP server
the validation controls are not working
what is going on pls help me?????????


B.
on April 29, 2005

BRIAN'S SOLUTION WORKS!!!!

Brian, thank you so much for taking the time to post a fix to this problem.

After hours of research and rechecking my own code, this site was the only one that explained this issue!

Microsoft should really make a point of highlighting this issue on the MSDN and Asp.net site!!!!


Raj
on May 13, 2005

Brian,

Your solution fixed my problem with the validation controls. Thanks for the post, you saved my day.

Regards
Raj


Sanjay Patel
on May 30, 2005

hii

My ASP.NET pages work well on local PC, but when i upload all files on internet it is not working, it gives following errors.. [Chunk of HTML deleted]


Milan Negovan
on May 31, 2005

Sanjay, I had to delete the rather large chunk of HTML because, as this page states, the only HTML tag allowed in a hyperlink. Let's try this again, but please use the preview button first.


Mike Holmes
on June 6, 2005

I am having the same problem as sonjay. Everything is perfect on the local host. But on the hosted site, the incorrect text is entered into my database even though the validation error shows up like it should.


Mike Holmes
on June 6, 2005

The paragraph at the top of the page fixed my problem...

If CheckPassword(SSN) = false and CheckName(PlayerName) = false and PAGE.ISVALID then...


Shaun
on June 8, 2005

Well done Brian - worked for me. Thanks!


Chuck
on June 8, 2005

I am seeing this problem. However, my problem occurrs across all browsers.

I had recently changed my work machine and reinstalled everything. I pulled my old harddrive and put it in the new one. I copied over all the old work into my local wwwroot dir. I am noticing that all of my validation control no longer work. They will trigger the error, but doesn't stop the process from continuing.

am I missing a crucial global file somewhere? I have all the aspnet_client stuff in the right place. I'm stumped


Earnie Eng
on June 29, 2005

Just briefly browsing the posts in this thread, I don't see a definite answer to why the ASP.NET validation didn't work, however, when I did a file-search on my server, I found the aspnet_clients folder in the wwwroot of the server. This folder wasn't in the root folder of one of the many sites I had on this server. I did a simple copy/paste of that folder in wwwroot to my root folder of my web page, and all the validation worked!

Is this necessary? To have to manually copy the aspnet_clients content to each of the websites I set on my web server to ensure validation works properly?


Milan Negovan
on June 30, 2005

As far as I know, you don't have to copy aspnet_clients into each web app root, but there's no harm in doing it.


Prasad Patnaik
on July 14, 2005

I tried a lot, i have client side Required validators but thy do not stop the post back.


asiya
on July 28, 2005

Well my problem is little bit different, Validators were not working on server as there no access to s_client folder on wwwroot due to company policy. They allowed us to move folder to appliction directory. We did and controls started working but amazingly button control stopped posting request to the server side.it does client validation but does not passes control to server.
Please any body can help me in this regard as thios is very urgent.


Niranjan
on August 5, 2005

i am using VS2003 ASP.NET 1.1 after validation my server sude button is not working.what shall i do.Please send the soln i will be greatful to you.it is very very urgent.


my mail Id
niranjanprusty@yahoo.com


Ramasamy
on August 22, 2005

I had a problem in Saving a whole folder image in server machine.
Now the problem is if i give C:\Image folder then the server code only look into the server machine C:\Image folder.
Please give me need full

Thanks
Rams


MikeD1MikeD
on August 23, 2005

Before you attempt to Register or Login, look for the View Code button at the bottom of the Authentication page. Next, you will be taken to my page that this applied to.


Rob
on August 25, 2005

Here is what fixed mine.

Open the WebUIValidation.js file in a text editor. The file is located in
[domain root]/aspnet_client/system_web/1_1_4322.
Locate the function ValidatorCommonOnSubmit.
Change it by adding return event.returnValue; as the last line:

function ValidatorCommonOnSubmit() {
event.returnValue = !Page_BlockSubmit;
Page_BlockSubmit = false;
return event.returnValue;
}

I found this solution at

http://aspalliance.com/699


najam sikander
on August 31, 2005

hey Rob

thanks for this little tip it really solved my problem man

thanks again and again


skicow
on September 30, 2005

Rob - Thanks for the link, lots of great info on using validators.


Angelo
on October 6, 2005

What helped me was to turn off the "enableclientscript" attribute in each validator. Let the server take care of the validation. I know this increases the postbacks and could degrade perfomance but it works.

It would appear that the same scripts added to asp.net to help in the validation of your application are the same scripts that could break your application.


Kuljit Saini
on November 16, 2005

I had similar problem of page not posting back. Thanks Rob. the link http://aspalliance.com/699 solved my problem.


Jesu Arasu
on November 18, 2005

Thanks a lot. I got the solution for this with in 10 min, only because of your details.
Thanks BRAIN.

Thanks everybody.


Deba Prasad
on November 28, 2005

I am creating validation controls dynamically. I have check box items on my screen. Clicking on any checkbox shows it's child controls and attach validation controls for child controls. Validation Controls don't work in some browser during first postback. By doing further analysis I found that the WebUIValidation.js is not included in first post back. Hence Validation Controls are not working. Any solution why though the validation controls are getting created (as I see SPAN tag for them) but WebUIValidation.js is not included ?
The client browser is IE6.0


Prakash Srinivasan
on January 9, 2006

Even I am having the same problem, but I am not facing this issue in all the pages. In one page, I have placed Required Field Validator & Range Vlidator Controls to validate the Textbox and Drop Down values. But it is not working properly. As well it is allowing me to submit the page and the record is also getting inserted into the Database.

If anyone have solution to this, please help me out in resolving this.


Davinder
on March 3, 2006

hello
I have a problem of validations.
i have dotnet2.0 version server. i want to deploy dotnet1.0 application but with this validations are not working.i attempted to upload the aspnet_client folder but on server it already exist that is not over writing.how it will be possible.

thanks
Davinder


Lee
on April 18, 2006

Hi guys, the problem is with a java script file in aspnet_client, microsoft have released a bad javascriptfile WebUIValidation.js which is included in evey page that has a validator on. This is how the function should look:

function ValidatorCommonOnSubmit() {
var result = !Page_BlockSubmit;
Page_BlockSubmit = false;
event.returnValue = result;
return result;
}

not

function ValidatorCommonOnSubmit() {
var result = !Page_BlockSubmit;
Page_BlockSubmit = false;
}

Thanks Microsoft, prob gates f**king with us all.


prasad patnaik
on April 19, 2006

Well
I really do not think it is a problem, it appears only when u include a client side validator or a link button, or any thing that need's a javascript Post back. and this is a feature not a problem


sai
on May 2, 2006

Hai,
I have a problem with validations. I have used no.of validations in my .aspx page. All the validations are working fine in the local system. But, no validation is working when the same page is uploaded into the server. I'm using asp.net 2.0 in my local system and in the server previous version is there.
Please anybody help

Thanks in advance


Pablo
on May 4, 2006

Well, my problem was that the validators worked, but then the submit buttons did nothing. I clicked them and nothing happened. No errors, no submit. The strangest thing was that it sometimes worked, sometimes not (i am not sure if i got a wrong impression on this because i began to make a lot of changes: copy aspnet_client, deleted it, created it as a virtual folder, etc)

Anyway, this solved my problem:

http://aspalliance.com/699#Page2

and

http://support.microsoft.com/default.aspx?scid=kb;en-us;889877

Hope this helps someone, I was really scared when I got that problem.


Netflash
on May 23, 2006

my case is fenomenal!

If i run a page with client validation using an IE browser 6.0 sp2 i get client side validation with no postback, but if run this using a IE browser 6.0 with no sp, i get validation but only after a postback! This didn't occur with .net 1.1. Client validation worked for both browsers without postbacks. The funny part is that if i use the validation samples from the asp.net Get Started samples, i get the same results but when i run the asp.net samples online, the work!

Has anyone tried this behavior?

Thank you.


Netflash
on May 23, 2006

I found the problem!

I was using an httpmodule (MSINC Compressor) to apply some compression to my webpages. It seems that with .net 2.0 using a compression HttpModule its not a very good choice since it kills all the clientside functionality. Besides MSINC i've tried also another one but with the same result.

Also it seems that wheni use an httpModule for compression, the parameter MaintainScrollPositionOnPostback stops working and it returns a javascript error.

I'm still going to try another HttpModule for compression (Flanders HttpCompression Module). Hope this one works... If anyone is using one HttoModule for compression that doesnt cause this side effects plz tell me!


Shan
on May 25, 2006

I have the problem of submitting the login form containing 2 text boxes and 2 RequiredFieldValidator. Its not submitting at all even if all it pass the Validations. I have seen this is due to after installing .NET Framework 1.1 SP1. Before it was working fine.

I have created new project similar to the same login page with MS Visual Studio.Net 2002 IDE, thats also giving the same problem. I have checked aspnet_client folder. It is there in the IIS Root. I have reinstall the Clientside scripts by aspnet_regiis -c also. Still its not working.

And i dont know how to uninstall the SP1 of .NET 1.1.

Win'2000 Server SP4-OS
VS.NET 2002 IDE
IE 6.0 SP1

Please anyone find the exact soln, mail me to this, shantnj@gmail.com. It would be great thankful.


Shan
on May 25, 2006

Thanx Brian, Its worked great after removing and reinstalling the clientscripts. It was a 2 days head ache solved today due to u. Thank you very much.

-SHAN


Empleado del mes
on June 8, 2006

Que desfas, Brian!!!!!


Saravanan
on June 29, 2006

Hay guys... u helped me a lot..
After I was wasting my one hour RND in my machine. i found out this URL from google...

thanks a lot guys


Matthew
on July 31, 2006

Hello all,

I think I'm getting this problem with ASP.net version 2, on my local development machine, client side script was simply not firing, and also noticed that if I set client side script to false using dynamically created validators then the server side validated were not working.

Nevertheless, as a simple test I have a single page with one text box and one required validator and the client side validation is not working, I have tried using the fix from Brian above, but get the following

C:\Documents and Settings\matt
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\asp
net_regiis.exe -ea
Start removing the ASP.NET client script files for all versions.
Finished removing the ASP.NET client script files for all versions.

C:\Documents and Settings\matt>>
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\asp
net_regiis.exe -c
Start copying the ASP.NET client script files for this version (2.0.50727).
An error has occurred: 0x80070003 The system cannot find the path specified.

Completely stuck, any ideas?

Regards,

Matthew


Kieran
on August 7, 2006

>>Funny, but I had this same problem a week ago.. what I did was I opened IIS, open the properties of the site.. remove the application and create the application. It worked. (Actually, before I came up with this situation, I also browsed through so many "help" sites but to no avail) Just like the article above.. what they are telling is that make sure you have the asp_client folder. It would really be cool if somebody could explain this "phenomenon".. hehehehe.. Nice article. Now I know that Im not alone.

This worked for me too. Also needed to tweak the web.config to get it to refresh for me.

Hallelulia!
Kieran


Adnan
on January 23, 2007

Thanks Pablo,
Though ur article is an old one, but its very useful and worked for me.


sankar
on February 23, 2007

Hi,

I have a similar problem..My site works fine with all my validators on the local machine..I hosted the files to test server and none of my validators get fired..Pls help me out...any suggestions will help me..

THanks,


Wayne
on February 26, 2007

There is a microsoft knowledge base patch for this problem - see KB822734


Ashwani
on April 16, 2007

Can any one Tell me the Problem i am facing...


I had deployed an site ...


The problem i am facing after deploying is the Validation control not allowing the button click event to fire..(Means it not allowing the page to be posted even if all the condition are met)

My code is locally running fine but when i am hosting it ...
It is creating problem..


Can any budy help me regarding this context....


If any message plz mail me reminder mail at my email id..


Thanks


Adam
on May 29, 2007

Brian, comment 13 is a life saver. I don't see me ever figuring that one out. THANKS!!!!!


Sumon
on May 30, 2007

Brian,
Thanks for your solution. It really works for me.

Thanks,

Sumon


Anil Kumar
on July 23, 2007

i wrote javascript validations for the credit card validations, when i am checking for the validations, they are firing but page processing is still continuing. I want the page to be still there, but after displaying the alert message the page is traversing to other , it should be there itself, i can't understand why it happens


Stuart
on September 26, 2007

Hi
I'm wanting to override the client side output from the ValidationSummary control in a Asp.Net 2 ste, which means no explicit js file, but an embedded one via WebResource.axd. Any suggestions on how I might get to the appropriate function (I assume ValidationSummaryOnSubmit) in order to alter what is coming out from it?
Cheers


Milan Negovan
on September 28, 2007

Stuart, do you think you can post this question in this forum? A friend of mine, Peter Blum, may have a good answer for you there.


puja
on October 24, 2007

Thanks ROB,

Thanks for the Solution..
Really It helped me out..


Thanks again


Nikesh
on February 18, 2008

my button's click event stopped firing after i got some javascript runtime error for validationsummary control.
i tried all the solutions like deleting and reinstalling the asp_client folder but still the problem persists. i have to do UseSubmitBehaviour=False in order to fire click event of that button.
but then i dont get the values entered in the textboxes on that page.
please help me out.


Kaustubh
on May 2, 2008

Hi,
I have some strange problem with validation controls. Here I explaining.

I have a table tag (runat="server") under which I have some text boxes and validation controls. Initially (on page load) I have kept table tag visible false. But I can toggle it visibly true/false through some image button click.
When I make the table tag visible true and input some data in text boxes my validation controls are not validating the input data.

But if I keep the table tag initially visible and then toggle it to visibly true/false then validation controls work fine.
I don't know what's the cause behind this. Kindly help solve this issue.
Thank you.


Krish
on May 7, 2008

Hey thanks Rob, its really solved my problem i was thinking to change all of my server side validations because of this problem but finally i got the solution with u r post
thanks a lot!


Parag Desai
on June 4, 2008

You can try using Other Alternate Browsers, if problem is really with your Internet Browser or the system.


Greg
on July 13, 2008

I have a similar but not identical problem... You can read about it here:

http://greg.berlin.net.au/2008/7/10/validatorhookupcontrolid-is-not-defined-in-aspnet-11.aspx

Basically, in a nutshell, Firefox complains that "ValidatorHookupControlID is not defined", even though it works fine in IE.

I was really hoping that Brian's solution of re-registering the client validation code would work, but it didn't.

Any other ideas??


Greg
on July 13, 2008

Answering my own question.. turns out ASP.Net 1.x just doesn't output the client side code for non-IE browsers. So when i try to call the javascript function to hook up the custom validators, Firefox throws errors.

Why oh why would a company still use .Net 1.x in a production environment??? arrrrrgh!

(full details at my blog: http://greg.berlin.net.au/2008/7/10/validatorhookupcontrolid-is-not-defined-in-aspnet-11.aspx)


Milan Negovan
on July 14, 2008

ASP.NET 1.x used to thumb its nose at non-IE browsers as "down-level" and didn't produce adequate markup or client-side scripts.


Greg
on July 14, 2008

Yeah... now who's having the last laugh? Certainly not microsoft with their Internet Explorer! Unfortunate for the poor developers stuck trying to support applications written on .net 1, and trying to make it cross-browser compatible. TG for jquery i say!


Indian
on August 19, 2008

I am using asp.net 2003

In a web page I have a dropdown list and a GO button which will take to the next screen depending on the item selected

On page load I want a dropdown list to be populated and for this the function is

Gettrainingrequests();

Now my Page_ Load looks like

if (!this.IsPostBack)
{
Gettrainingrequests();
binddata();
}
else
{

binddata();
}

1) If I omit the else part in the if statement I am getting empty dropdown list (dorp down list not populated)

2) If I retain the else part in if statement the first element will always be triggered whenever I click GO button (the selected value is not triggered)

Please suggest me the solution for this.

Thanks in Advance


Chandu
on August 22, 2008

Brian (comment 13),

Thanks a lot. you saved my day.
your is the best solution


Julian
on January 26, 2009

Also make sure that if you're using .net 2.0 framework that you have service pack 1 installed, sp2 was just released as well.


Maynard Leigh
on September 29, 2009

I used validation in my web app. And running them locally but my problem is when copy it , it vanish the whole script.


Kamran Ahmed
on February 18, 2010

Thanks a lot Brian. you saved lot of effort.


Kamran Ahmed
on February 18, 2010

Thanks a lot Brian. you saved lot of effort


Leave a comment

  •