JS Debugging does not work (VS2008 beta2)

Last post 08-02-2007 2:53 AM by stez. 4 replies.

Sort Posts:

  • JS Debugging does not work (VS2008 beta2)

    08-01-2007, 6:41 AM
    • Member
      45 point Member
    • stez
    • Member since 08-12-2002, 10:28 PM
    • Kortrijk - Belgium
    • Posts 12

    Consider the code belowin my aspx file. When i set a breakpoint on the line "alert(ik)" the debugger never stops there. The code executes normally, so i see the alert box. but it never hits the breapoint.

    Steps i've taken:

    • I have firefox as default browser on my system
    • After installing the beta of VS2008. Created a new website and entered the code below.
    • Right-clicked on the default.aspx file and set Internet explorer as the default browser there.
    • Enabled script debugging in IE  (only for IE, not for others)
    • F5 :)
    • Nothing happens in the debugger, but the code executes normally

     

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_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">
        <title>Untitled Page</title>
        <script type="text/javascript">
    		function test()
    		{
    			var ik = "";
    			ik = "ddfqsdqsd"
    			alert(ik); //breakpoint here
    		}
        </script>
    </head>
    <body onload="alert();">
        <form id="form1" runat="server">
        <div>
    		</div>
        </form>
    </body>
    </html>
    
      
  • Re: JS Debugging does not work (VS2008 beta2)

    08-01-2007, 8:03 AM
    • Member
      214 point Member
    • CDERUE
    • Member since 07-06-2007, 9:31 AM
    • Posts 42

     Hi,

    If you want to debug Javascript with Visual Studio, insert the keyword 'debugger' in your script. It acts as a breakpoint.

    <script type="text/javascript">
    function test()
    {
    var ik = "";
    			debugger;
    ik = "ddfqsdqsd"
    alert(ik); //breakpoint here
    }
    </script>
     
    Cédric 
  • Re: JS Debugging does not work (VS2008 beta2)

    08-01-2007, 8:18 AM
    • Member
      45 point Member
    • stez
    • Member since 08-12-2002, 10:28 PM
    • Kortrijk - Belgium
    • Posts 12

    That doesn't work.

     I never read such a statement "debugger;" before by the way. (for example in the blog posts of scott guthrie on the subject of Orcas JS debugging)

  • Re: JS Debugging does not work (VS2008 beta2)

    08-01-2007, 10:34 PM
    • Participant
      1,410 point Participant
    • Jeff.aspx
    • Member since 09-12-2003, 2:16 AM
    • Redmond, WA
    • Posts 252
    • AspNetTeam
      Moderator

    The "debugger" is a valid construct for simulating a breakpoint.  However, with VS2008, using the breakpoint is just much easier.

    I noticed in your code that the function test() is never called nor referenced.  The alert box that you see if due to a separate call to alert() assigned to the body.onload.  Perhaps you meant to assign test to the body.onload?

    Jeff King
    Program Manager
    ASP.net
  • Re: JS Debugging does not work (VS2008 beta2)

    08-02-2007, 2:53 AM
    Answer
    • Member
      45 point Member
    • stez
    • Member since 08-12-2002, 10:28 PM
    • Kortrijk - Belgium
    • Posts 12

    Woops typo in the example. I called the function Test(); in the onload off course....

     But yesterday evening i re-installed visual studio on my machine (new clean vista install) and now it seems to work... so problem solved i guess :)

Page 1 of 1 (5 items)