none
Can't Debug JavaScript in VS 2008 RRS feed

  • Question

  • Hi All,

    I have similar question to many others have asked before me. I can't debug JavaScript in my VS 2008 project.

    Following is pretty much what I am testing.

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Debug_Test._Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">

       <%-- <script src="Test.js" type="text/javascript"></script>--%>
        <script type="text/javascript">
            function showMessage() {
                debugger;
                alert("This is just a Test");
            }
        </script>
        <title>Test Page</title>
        <style type="text/css">
            #Button1
            {
                width: 86px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <input id="Button1" name="Click" type="submit" onclick="showMessage()" />
            <%--<asp:Button ID="Button1" runat="server" Text="Test" OnClick="showMessage();" />--%>
        </div>
        </form>
    </body>
    </html>

     

    And my application doesnt stop on breakpoint. I have de-selected both debugging options from my IE 8. And have cleared browsing history (though this should not effect). If I keep that "Debugger" I get following message (which again makes no sense to me)

     

    ---------------------------
    Microsoft Visual Studio
    ---------------------------
    There is no source code available for the current location.
    ---------------------------
    OK  
    ---------------------------

    And If I comment out "Debugger" application will just bypass the breakpoint.

    I dont know if I am missing something here. I will really appreciate it if anyone can suggest me something else.

    Just for info, I am using Windows 7, VS 2008 Pro (Version 9.0)) and Project is build using .NET Framework 2

    Thanks,

    Jack



    • Edited by Jack Locke Wednesday, June 15, 2011 7:23 PM added more description
    Wednesday, June 15, 2011 7:19 PM

Answers

  • You may try following steps to debug JavaScript:

     

    1. Set IE options: clear "Disable script debugging" checkboxes.

    2. Open web application in Visual Studio.

    3. Set breakpoint at JavaScript functions.

    4. Press F5 to launch debugging session.

    5. Open Processes windows by selecting Debug menu -> Windows -> Processes, and you can see WebDev.WebServer.Exe process there.

    6. Choose Tools menu -> Attach to Process. On the pop up window, select iexplorer.exe process, which has type of Script, x86 (or x64), and click the Attach button to attach to IE process.

    7. Now, once the JavaScript functions get executed, breakpoint will hit.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Kris444 Tuesday, June 21, 2011 10:57 AM
    • Marked as answer by Jack Locke Thursday, June 23, 2011 5:36 PM
    Friday, June 17, 2011 2:02 AM
  • Thanks Eric for your reply.

    By following steps you mentioned it works just fine ....

    But originally i was able to debug scipt just by placing breakpoints and then running the application. And somehow i lost that "functionality" in time. But after I did reset my "web development environment" by going into tools -> import/export settings -> Reset All Settings,  I was able to debug scipt without going through this complex process you mentioned :)...

     

    -Jack


    • Marked as answer by Jack Locke Thursday, June 23, 2011 5:42 PM
    Thursday, June 23, 2011 5:39 PM

All replies

  • You may try following steps to debug JavaScript:

     

    1. Set IE options: clear "Disable script debugging" checkboxes.

    2. Open web application in Visual Studio.

    3. Set breakpoint at JavaScript functions.

    4. Press F5 to launch debugging session.

    5. Open Processes windows by selecting Debug menu -> Windows -> Processes, and you can see WebDev.WebServer.Exe process there.

    6. Choose Tools menu -> Attach to Process. On the pop up window, select iexplorer.exe process, which has type of Script, x86 (or x64), and click the Attach button to attach to IE process.

    7. Now, once the JavaScript functions get executed, breakpoint will hit.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Kris444 Tuesday, June 21, 2011 10:57 AM
    • Marked as answer by Jack Locke Thursday, June 23, 2011 5:36 PM
    Friday, June 17, 2011 2:02 AM
  • Thanks Eric for your reply.

    By following steps you mentioned it works just fine ....

    But originally i was able to debug scipt just by placing breakpoints and then running the application. And somehow i lost that "functionality" in time. But after I did reset my "web development environment" by going into tools -> import/export settings -> Reset All Settings,  I was able to debug scipt without going through this complex process you mentioned :)...

     

    -Jack


    • Marked as answer by Jack Locke Thursday, June 23, 2011 5:42 PM
    Thursday, June 23, 2011 5:39 PM
  • Thank you so much!! Finally I can debug this piece of ****... Joke, This is literally very far-fetched if you doesn't know how to configure it... Thank you very much!
    Tuesday, August 20, 2019 9:03 PM