Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript failing on Windows 7 machine

    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:

    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-...anel-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!

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    Does the page reload at all? Or does the page reload, but nothing happens after that?
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    New Coder
    Join Date
    Nov 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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.)
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #5
    New Coder
    Join Date
    Nov 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,449
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    Quote Originally Posted by mellomel70 View Post
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    New Coder
    Join Date
    Nov 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, I know I can debug javascript. I'm doing so, but when I get to the browser-generated script:

    Code:
    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?

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,449
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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 though. Maybe. Worth a try.

    I still suspect the problem isn't directly attributable to javascript.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,449
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    Quote Originally Posted by chump2877 View Post
    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 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/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #12
    New Coder
    Join Date
    Nov 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #13
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,740
    Thanks
    41
    Thanked 191 Times in 190 Posts
    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?

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #14
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,449
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    Quote Originally Posted by mellomel70 View Post
    BTW, I'm a "she" not a "he"!
    Treat it as the gender-neutral "he" of most legal documents. <grin/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    LinkBacks (?)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •