...

View Full Version : Javascript failing on Windows 7 machine



mellomel70
12-19-2011, 08:23 PM
Hi - I have an ASP.Net 4.0 solution that runs fine on a Windows 2008 server. However, I've just been given a new Windows 7 64-bit machine to use as my development machine and I'm having a problem with one of my aspx pages. This page has some javascript on it, which runs fine, but then it gets to the following code:



<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>

This not code that I've written; it's code that's generated client-side that I see as I'm debugging my app in Visual Studio 2010 (trying to figure out what the $^#$ is going on). At any rate, once this code completes, the app does nothing. The debugger should take me to some server-side code, but it doesn't. It just sits there. The result is that the page doesn't do what it's supposed to do (no inserts to databases, no success messages, no nothing).

As I said, this problem is restricted to my W7 64-bit machine; it runs fine on W2008. Other pages with javascript in the same solution work fine on my W7 machine. I found a post (http://dopostback.net/index.php/net-framework-4-0-update-panel-problems/) that discusses a similar issue within an UpdatePanel, but I'm not using UpdatePanel. My page does have hidden controls on it, but so do other pages that work just fine. Does anyone know what could be causing this?

Thanks!

chump2877
12-20-2011, 04:34 AM
Does the page reload at all? Or does the page reload, but nothing happens after that?

mellomel70
12-20-2011, 02:49 PM
Yes, it does do a post back, but never goes to the server-side code that the button click is supposed to invoke. It just goes to the client-side code, then a post back, then nothing.

chump2877
12-20-2011, 03:34 PM
Is there any way to check the values of __doPostBack() arguments before the form submits? I don't know what those values are supposed to be (normally), but other than the setting of those form values prior to form.submit(), it seems to me that the javascript is actually in fact doing what it's supposed to do -- submit and post the form to the server. So perhaps this isn't a javascript issue per se, but a .NET issue? (Maybe that seems like an obvious conclusion -- but this is a Javascript forum. So you might have more luck asking someone in the ASP.NET forum.)

mellomel70
12-20-2011, 03:40 PM
Visual Studio doesn't seem to allow me to see what the values are. I will post this problem on .Net forums also - that's a good idea, thanks. I posted here because it seems like the page is getting lost (i.e., not going where it's supposed to) once the javascript finishes. But perhaps that's not the problem. Anyway, thanks for your help.

chump2877
12-20-2011, 03:50 PM
I posted here because it seems like the page is getting lost (i.e., not going where it's supposed to) once the javascript finishes.

What is the action of the form? Unless you are defining the action in javascript, you can see that directly in your markup.

If the action is correct, then it sounds like it might be a server side issue that occurs after the form submits.

Old Pedant
12-20-2011, 09:21 PM
Visual Studio doesn't seem to allow me to see what the values are.

Not true.

You *CAN* debug JavaScript code, in the browser, using Visual Studio.

Or, if you are using MSIE 9, you can use the JavaScript debugger that is built right into MSIE.

mellomel70
12-20-2011, 09:33 PM
Yes, I know I can debug javascript. I'm doing so, but when I get to the browser-generated script:


if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}

I can't see any of the values; Visual Studio 2010 tells me that they don't exist. How can I debug from within IE9?

Old Pedant
12-21-2011, 02:01 AM
You have to enable client side debugging before VS will be able to debug JS code. That applies to MSIE 7 and 8.

In MSIE 9, though, it's much easier to use the builtin debugger. Just hit the F12 key and voila!

Click on SCRIPT and you are ready to set breakpoints, inspect variables, etc.

chump2877
12-21-2011, 02:11 AM
I dont think he can set breakpoints on that specific javascript in VS because that javascript isnt generated until his code is compiled.

He might be able to set a breakpoint in IE's developer tools (http://msdn.microsoft.com/en-us/library/gg699336(v=VS.85).aspx) though. Maybe. Worth a try.

I still suspect the problem isn't directly attributable to javascript.

Old Pedant
12-21-2011, 04:16 AM
I dont think he can set breakpoints on that specific javascript in VS because that javascript isnt generated until his code is compiled.

He can't do it as part of his VS project. But he can as an independent debugging of any web page. Might have to use a new instance of VS, not the one hosting the project. I used to do it all the time when using MSIE 7 and VS (granted, I was using VS for HTML and ASP pages, not ASP.NET, but still...It's just a matter of setting the right "Advance" options in Internet Options from Tools menu.



He might be able to set a breakpoint in IE's developer tools (http://msdn.microsoft.com/en-us/library/gg699336(v=VS.85).aspx) though. Maybe. Worth a try.I can't imagine why he couldn't. The client-side development tools have no idea his code is coming from ASP.NET, for that matter.




I still suspect the problem isn't directly attributable to javascript.
I'm certainly not going to give you any odds *against* that being true! If anything, you should give me long odds if I bet the other way. <grin/>

mellomel70
12-21-2011, 04:21 PM
Thanks for all the info, folks! BTW, I'm a "she" not a "he"! I was reading your posts and it took me a minute to realize who this "he" was you were talking about! :D

alykins
12-21-2011, 06:36 PM
when using VS to debug JS you must have IE as your default browser (the only reason IE is my default browser) it threw me through loops for weeks to figure out why my code was not dropping into debug on mine but my buddy was dropping in fine... the only difference was he had IE as default and i had chrome...
if using VS and Ie as defaulted browser and running debug then the break points set in VS will break no problem- i do it all the time in VS 2008 and VS 2010 and across IE platforms (from IE7-IE9)
eg
@ work we have a project in VS2008 and are limited to IE7- debugged js no problem
@ work we have project in VS2010 as well (still limited to IE7) debugged js no problem
@ work new project in VS2010 testing on unupdated Win7 (IE8) and debug no problem
@ home I run VS2010 and debug via IE9 no problem

pm me if any specific Q's hope that helps :)

once in VS debug whle new world of starts open to you- I assume since you were trying to get it to break in VS you already know debug methods?

Old Pedant
12-21-2011, 08:23 PM
BTW, I'm a "she" not a "he"!

Treat it as the gender-neutral "he" of most legal documents. <grin/>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum