Why will Visual Studio 2005 not debug my JavaScript code?

In this very simple ASP.NET application, Visual Web Developer 2008 Express CAN debug the JavaScript code fine, but the full version of Visual Studio 2005 CANNOT debug it, namely: when I click on a line in the main.js file it gives me a red circle with a question mark on it, the mouse hover revealing: “This break point will not be reached, no symbols were loaded for this document.”

What do I have to do to my Visual Studio 2005 so that it debugs JavaScript code like my Visual Web Developer 2008?

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestJavascriptDebugging2005._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 type="text/javascript" src="javascript/main.js"></script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <p>This is HTML and <script type="text/javascript">test()</script>.</p>
                <p><button onclick="doIt(this)">Test</button></p>
            </div>
        </form>
    </body>
</html>

javascript/main.js:

function test() {
    document.write("this is from javascript code2");
}

function doIt(element) {
    alert("This is the javascript function2.");
}

3 thoughts on “Why will Visual Studio 2005 not debug my JavaScript code?

  1. user

    Integrated JavaScript debugging is a new feature of VS2008 – or at least, it’s much improved

    If you search for “visual studio 2008 new features javascript debugging” you’ll get lots of informative hits.

    It’s not unreasonable for a newer version of an IDE (even the Express edition) to have more features than an older version.

    EDIT: Although JavaScript debugging was present in VS2005, it’s better integrated in VS2008, and one of the new features is the ability to place breakpoints in JS code.

    Reply
  2. user

    Check if the following things are followed:

    i. Enable script debugging in IE.

    ii. Open the client side script in the script explorer, and there you are happy debugging.

    For details on how to accomplish this, please go through the following link from which I originally picked up this trick.

    1. Debugging client javascript in VS2005.
    2. A Kb from Microsoft explaining the same.
    Reply
  3. user

    To be clear, Visual Studio 2005 does support JavaScript debugging. It just isn’t able to resolve break points set on files with lines in source scripts in the browser.

    In Visual Studio 2005 you can place the debugger directive in the JavaScript code at the point you want to break. From there you can open the Scripts Explorer window and set break points in the source scripts (as seen from the browsers perspective).

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *