Scott on Writing

Musings on technical writing...

Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box

I got a call from a colleague I had done some work for who was having some problems with a some pages I had whipped up for him a few months back.  In between then and now, the Web server had died and was rebuilt.  After the rebuild, though, some pages submit buttons stopped working altogether.  One would go to a page, fill in the form values, and click the Submit button and... nothing would happen.  No error.  No message on the screen.  No sending to a blank page.  No postback.  Just nothing.

You can imagine how much fun our conversation became when I visited the URL my colleague was having a problem with and... everything worked perfectly for me.  I could not repro any of the behavior he was experiencing.  After a few confused and frustrating minutes I realized that he was probably using IE and here I was using FireFox, so I switched to IE and was able to repro the problem.  This clued me into the source of the problem being the client-side validation used by the page, since this client-side validation was not emitted to “downlevel” browsers like FireFox.

I visited the page and attached the Visual Studio .NET debugger to do script debugging on IE.  I found that the problem was in the form statement, where there was:

<form ... onsubmit="if (!ValidatorOnSubmit()) return false;" ...>

Now, if a form's onsubmit event handler returns false it short-circuits the form submission process, and the return statement was executing through the debugger, so that popped out as the problem.  But why was it returning false?  Shouldn't it not do that?  To try to better understand what was going on, I poked through the ValidatorOnSubmit() function, whose code is shown below:

function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    return true;
}

The ValidatorCommonOnSubmit() method, I found, was located in WebUIValidation.js.  Looking at that function I found the following code:

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

I am not a JavaScript expert in the least, but this function looked a bit odd.  Shouldn't it be returning a value?  Perhaps, I reasoned, the event.returnValue was setting the return value of the function.  But then why was ValidatorOnSubmit() returning false?  I decided to Google “validatoronsubmit returning false” which turned up a single result, a blog entry by Thomas Freudenberg that described the exact same problem and a workaround.

In a nutshell a hotfix for the .NET Framework 1.1 causes this problem, as it has the WebUIValidation.js file and the onsubmit event handler in the form tag out of sync.  If you have the ValidatorCommonOnSubmit() function like the one shown above the onsubmit event handler should just have onsubmit="ValidatorOnSubmit();".  If, however, you have the onsubmit event handler as shown above (onsubmit="if (!ValidatorOnSubmit()) return false;") then the ValidatorCommonOnSubmit() function should return the value of !Page_BlockSubmit (the value of Page_BlockSubmit before it's set to false).

Basically the hotfix puts the rendered onsubmit out of sync with the WebUIValidation.js file.  So if you have installed the hotfix - as my colleague had when rebuilding the Web server - then you will need to update the ValidatorCommonOnSubmit() function in WebUIValidation.js so that it looks something like:

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

 

posted on Saturday, January 08, 2005 10:36 AM

Feedback

# I pulsanti di ASP.NET non funzionano pi 1/8/2005 2:21 PM Alberto Falossi's Blog (Italiano)

# I pulsanti di ASP.NET non funzionano pi 1/8/2005 2:22 PM Alberto Falossi's Blog (Italiano)

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 1/8/2005 4:27 PM Scott Elkin

You have made my day.

Over the course of the last few months, I would have this happen to me out of the blue. Just recently it happened when trying to use Community Server.

Thank you so much for pushing through and finding the cause.

And on a personal note, I am heading out to Indonesia to help with the relief efforts on Tuesday. This was one problem that was definately on my very long things-that-must-be-solved-before-i-can-go todo list.

So, thanks again!

# Validators Not Submitting on an ASP.NET Form 1/8/2005 4:56 PM Scott Elkin

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 1/9/2005 11:23 PM hutch@clearlakeservices.com

Way to go, Scott! You just fixed my web page! Frankly, I had no clue what was wrong with it until I stumbled across your blog article.

Thanks

# [Asp.Net] Quando i pulsanti smettono di funzionare 1/14/2005 3:22 AM :: AB ::

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 1/18/2005 3:03 AM Mun

Thanks Scott! Your fix worked like a dream! :-)

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 1/18/2005 11:00 AM Richard

Thanks for the info. I had spents hours trying to figure out why my computer was the only one having the problem.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 1/19/2005 4:29 PM Rich B from Philly

THANK YOU SCOTT. I was working on this issue for 3 hours before I stumbled upon this blog... 'thank you' to YOU and GOOGLE!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 1/24/2005 3:46 PM Patrick Sikes

This MS KB bug article popped up too. Check out http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B889877. It describes using aspnet_regiis.exe -c to fix the problem. Did not work for me though because aspnet_regiis.exe would not run...something about admin rights which I had...

Thanks for the other route to fix the problem.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 2/4/2005 12:00 PM Chris Keeble

Also couldn't get the Microsoft method to work - and don't really understand why some of the sites on our server were ok, and this particular one not. Can anyone shed any light on this?

Found that copying the WebUIValidation.js file from the default wwwroot was the best way to fix this for us (also keeps the file creation / modified date correct so easier to spot the problem in future).

Thanks to everyone that has helped me solve this - it's cost us hours today like every other poor soul out there.

Good old Microsoft idiots as always.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 2/6/2005 8:08 PM Mac Jones

Scott, sick of hearing this ???

YOU ROCK, well done !

Cheers
Mac

# Thank you blog world 2/7/2005 11:03 AM Scott Cate's WebLog

# Thank you blog world 2/7/2005 11:03 AM Scott Cate's WebLog

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 2/7/2005 11:12 AM Blair Stephenon

Hey Chris Keeble,

The 1.1 SP1 fix only updates the javascript code to the default web site on a server. You need to manually copy the file to each web site. We just do a compare and make sure everything is the same.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 2/8/2005 9:50 PM Cheers Scot

it s amazing, i got stuck with the same for hours, thanks a lot

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 2/11/2005 2:06 PM Joe C

this saved me allot of headaches......thank you!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 2/14/2005 12:00 PM balu

Thanks.

Save my life amidst a tight deadline.

Will buy your "planned" asp .net 2.0 book. Write it with C# please.

balu.

# I pulsanti di ASP.NET non funzionano pi&amp;#249;? Ecco il perch&amp;#233;. 2/24/2005 6:07 AM Blog2theMax

Grazie a questo post di Scott Mitchell ho risolto finalmente uno dei misteri più strani degli ultimi...

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 2/26/2005 4:29 PM Drew

Yet another person thanking you! Two days of frustration are now over!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 3/7/2005 2:34 PM Kenny Lai

Thanks a bunch, i just applied this service pack this weekend and was wondering wtf was going on!

good job!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 3/9/2005 3:54 PM HAG

OMG!!! THANK the LORD! You Rock and thanks for the patch!!!

-HAG

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 3/10/2005 9:16 AM Mike

Thanks Dude !!!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 3/23/2005 1:08 AM Karl

Nice One!!! 10 minutes before a critical demo, my production version not working.... find your article. Bingo!!!!

Thank you ever so much

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 3/24/2005 10:18 AM Dirk

Thanks. I can't believe microsoft sometimes... sheesh.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 3/24/2005 12:11 PM Dirk

We had a site on 2k then upgraded to 2003 with the patch. This fixed the issue right up. Thank you so much!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 4/7/2005 1:07 PM Chris

Thanks dude ... fantastic!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 4/15/2005 7:06 AM SuzyB

I'm so glad I remembered this entry. It's saved me hours of work.

Thanks.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 4/21/2005 4:16 AM deride

My problem is similar, I need to call another javascript function regardless of whether or not ValidatorOnSubmit() is true or false. My WebUIValidation.js is the latest i.e
function ValidatorCommonOnSubmit() {
var result = !Page_BlockSubmit;
Page_BlockSubmit = false;
event.returnValue = result;
return result;
}
But still my form has onsubmit = "if (!ValidatorOnSubmit()) return false; MyFunction()"
Hence MyFunction() is not being called when the validation fails. I want it to be called everytime.. how can I change this so that my function is also called??
Any help will be appreciated..

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 4/26/2005 12:22 PM Anderson Imes

I ran across this issue today. It seems as though when you install this patch, it updates ASP.NET, but it fails to copy the updated WebUIValidation.js file into its home on the server - only the copy in the %SystemRoot%\Microsoft.NET\Framework\v1.1.4332\ directory is changed.

To fix this, intead of updating the WebUIValidation.js file manually, force the new version to be deployed to your server by running aspnet_regiis -i against your web server. It will redeploy the contents of the \aspnet_client\ directory with the updated version of the WebUIValidation.js.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 5/9/2005 10:57 PM Yehiel

you did my day! thanks

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 5/13/2005 1:20 PM LikingLinuxMoreandMore

You would think M$ would have caught this in QA?

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 5/14/2005 12:29 PM ashraffayad@hotmail.com

Thanks a million. I had a hard time trying to solve this problem till I found your article. You are the best.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 5/20/2005 9:51 AM Alessandro Calzona

Thank You. It was hard to find you through msdn; maybe google is a better saerch engine even for ms developers ;-)
Thanks again

# Form with validators not posting? (Framework 1.1) 5/28/2005 12:09 AM Joteke's Blog

# Form with validators not posting? (Framework 1.1) 5/28/2005 12:10 AM Joteke's Blog

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 6/8/2005 10:11 PM Eugene Sia

Thanks very much Scott for the tip, saved alot of time!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 7/29/2005 4:34 PM Josh

Thank you for this. Could not find it anywhere else on the web.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 8/8/2005 12:02 AM rajiv

thank you scott for your valuable information about the js files. which i got struck up for more than hour with the help of your code i can able to debug...

reg
rajiv

ceo
thylaksoft

# Form Validators Not Submitting on ASP.NET 1.1 8/16/2005 11:51 AM Wayne Larimore - his bloggin' Weighs

# Form Validators Not Submitting on ASP.NET 1.1 8/16/2005 11:52 AM Wayne Larimore - his bloggin' Weighs

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 8/23/2005 2:44 AM Prashant Atal

cool it worked like a charm and i had a similar problem on 2 of my clients servers and it saved on so many support calls.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 9/13/2005 1:22 PM Matt

Top man Scott...one of those 'pull your hair out' problems...keep up the good work!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 10/25/2005 8:28 PM Jeff Handley

I've seen this too, and just saw it again last week when getting a client's project set up on my machine. Their project included a copy of the WebValidationUI.js file.

After replacing the WebValidationUI.js file with the one from wwwroot, the problem did not go away.

However, I cleared by browser cache and viola! Too bad it took me about 15 minutes to think of that -- those were 15 frustrating minutes!

-Jeff

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 11/22/2005 3:14 PM steve will

I had this problem a long time ago and solved it a different way............however this way is far better more direct and better...cheers mate

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 1/19/2006 10:17 AM Tayo

I know you have heard this alot already, but thanks. This issue had already cost me alot of time until I came across this article

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 4/19/2006 8:12 AM Richard DeVaney

Should I ever meet you sometime in real life...Sir, I owe you a beer. (or beverage of your choice). This problem was giving me fits figuring it out. You saved the day.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 4/21/2006 12:54 PM Elusion

You made my day - CLient was asking for a refund.

Sod MS.

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 6/5/2006 7:17 AM Christophe

Thanks Scott! This is great it was very perlexing why my submit button did nothing!

# re: Form with Validators Not Submitting on a Rebuilt ASP.NET 1.1 Box 6/17/2006 5:40 AM Deepak

Awesome work! Thanks a ton!

# If only you'd posted this three days ealier... 7/5/2006 6:20 AM David

...you'd have saved me a couple of hours with the javascript debugger.
Thanks for this.

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

Add To Your Reader

My Links

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1866.8%
Monday 37913.9%
Tuesday 45316.7%
Wednesday 50418.5%
Thursday 53519.7%
Friday 49418.2%
Saturday 1666.1%
Total 2717100.0%

Hour1Total% of Total
12:00 AM 652.4%
1:00 AM 682.5%
2:00 AM 622.3%
3:00 AM 742.7%
4:00 AM 572.1%
5:00 AM 1033.8%
6:00 AM 1084.0%
7:00 AM 1585.8%
8:00 AM 1716.3%
9:00 AM 1475.4%
10:00 AM 1716.3%
11:00 AM 1816.7%
12:00 PM 1886.9%
1:00 PM 1696.2%
2:00 PM 1605.9%
3:00 PM 1324.9%
4:00 PM 1073.9%
5:00 PM 923.4%
6:00 PM 913.3%
7:00 PM 963.5%
8:00 PM 833.1%
9:00 PM 782.9%
10:00 PM 792.9%
11:00 PM 772.8%
Total 2717100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.54144
Monday 5.22339
Tuesday 4.28419
Wednesday 7.67637
Thursday 6.90607
Friday 5.48411
Saturday 5.33160
Total 5.842717

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.35107
9:00 AM 6.32278
10:00 AM 6.47246
11:00 AM 4.41181
12:00 PM 6.88330
1:00 PM 3.00111
2:00 PM 5.41222
3:00 PM 8.64285
4:00 PM 4.0589
5:00 PM 5.92154
6:00 PM 4.52113
7:00 PM 9.67174
8:00 PM 9.80147
9:00 PM 5.05111
10:00 PM 5.4265
11:00 PM 4.5732
Total 5.842717

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles