Skip navigation.

MSN Search Facelifts And MSN Search Technology PreviewAll recent postsBuilding Charts in VB.NET

Problems with Validation Controls in Internet Explorer

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.

Comments

Comment permalink 1 Ryan Farley |
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
Comment permalink 2 Scott Mitchell |
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?
Comment permalink 3 Milan Negovan |
The funny thing is the code was identical down to the last byte! This is why we figured we needed to look elsewhere.
Comment permalink 4 srinivas |
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?????????
Comment permalink 5 Milan Negovan |
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.
Comment permalink 6 David |
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?
Comment permalink 7 Milan Negovan |
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.
Comment permalink 8 David |
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
Comment permalink 9 RP |
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.
Comment permalink 10 MikeD |
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.
Comment permalink 11 Jay |
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.
Comment permalink 12 janetk |
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...
Comment permalink 13 Brian |
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.
Comment permalink 14 Premjeet |
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
Comment permalink 15 Lauren |
Brian - thanks so much for that very helpful info. All of my validation works perfectly again now. :)
Comment permalink 16 Gyanesh Mishra |
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?????????
Comment permalink 17 B. |
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!!!!
Comment permalink 18 Raj |
Brian,

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

Regards
Raj
Comment permalink 19 Sanjay Patel |
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]
Comment permalink 20 Milan Negovan |
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.
Comment permalink 21 Mike Holmes |
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.
Comment permalink 22 Mike Holmes |
The paragraph at the top of the page fixed my problem...

If CheckPassword(SSN) = false and CheckName(PlayerName) = false and PAGE.ISVALID then...
Comment permalink 23 Shaun |
Well done Brian - worked for me. Thanks!
Comment permalink 24 Chuck |
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
Comment permalink 25 Earnie Eng |
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?
Comment permalink 26 Milan Negovan |
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.
Comment permalink 27 Prasad Patnaik |
I tried a lot, i have client side Required validators but thy do not stop the post back.
Comment permalink 28 asiya |
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.
Comment permalink 29 Niranjan |
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
Comment permalink 30 Ramasamy |
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
Comment permalink 31 MikeD1MikeD |
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.
Comment permalink 32 Rob |
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
Comment permalink 33 najam sikander |
hey Rob

thanks for this little tip it really solved my problem man

thanks again and again
Comment permalink 34 skicow |
Rob - Thanks for the link, lots of great info on using validators.
Comment permalink 35 Angelo |
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.
Comment permalink 36 Kuljit Saini |
I had similar problem of page not posting back. Thanks Rob. the link http://aspalliance.com/699 solved my problem.
Comment permalink 37 Jesu Arasu |
Thanks a lot. I got the solution for this with in 10 min, only because of your details.
Thanks BRAIN.

Thanks everybody.
Comment permalink 38 Deba Prasad |
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
Comment permalink 39 Prakash Srinivasan |
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.
Comment permalink 40 Davinder |
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
Comment permalink 41 Lee |
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.
Comment permalink 42 prasad patnaik |
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
Comment permalink 43 sai |
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
Comment permalink 44 Pablo |
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.
Comment permalink 45 Netflash |
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.
Comment permalink 46 Netflash |
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!
Comment permalink 47 Shan |
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.
Comment permalink 48 Shan |
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
Comment permalink 49 Empleado del mes |
Que desfas, Brian!!!!!
Comment permalink 50 Saravanan |
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
Comment permalink 51 Matthew |
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
Comment permalink 52 Kieran |
>>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
Comment permalink 53 Adnan |
Thanks Pablo,
Though ur article is an old one, but its very useful and worked for me.
Comment permalink 54 sankar |
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,
Comment permalink 55 Wayne |
There is a microsoft knowledge base patch for this problem - see KB822734
Comment permalink 56 Ashwani |
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
Comment permalink 57 Adam |
Brian, comment 13 is a life saver. I don't see me ever figuring that one out. THANKS!!!!!
Comment permalink 58 Sumon |
Brian,
Thanks for your solution. It really works for me.

Thanks,

Sumon
Comment permalink 59 Anil Kumar |
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
Comment permalink 60 Stuart |
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
Comment permalink 61 Milan Negovan |
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.
Comment permalink 62 puja |
Thanks ROB,

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


Thanks again
Comment permalink 63 Nikesh |
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.
Comment permalink 64 Kaustubh |
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.
Comment permalink 65 Krish |
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!
Comment permalink 66 Parag Desai |
You can try using Other Alternate Browsers, if problem is really with your Internet Browser or the system.
Comment permalink 67 Greg |
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??
Comment permalink 68 Greg |
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)
Comment permalink 69 Milan Negovan |
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.
Comment permalink 70 Greg |
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!
Comment permalink 71 Indian |
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
Comment permalink 72 Chandu |
Brian (comment 13),

Thanks a lot. you saved my day.
your is the best solution
Comment permalink 73 Julian |
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.
Comment permalink 74 Maynard Leigh |
I used validation in my web app. And running them locally but my problem is when copy it , it vanish the whole script.
Comment permalink 75 Kamran Ahmed |
Thanks a lot Brian. you saved lot of effort.
Comment permalink 76 Kamran Ahmed |
Thanks a lot Brian. you saved lot of effort

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):