2

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 Answers 3

4

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.
Sign up to request clarification or add additional context in comments.

2 Comments

Cool - although it's obviously a lot simpler to just use the integrated version in VS2008 :)
I agree, life is simpler in VS 2008. Also another thing I personally prefer is to use a browser based debugger (firebug/firefox)
1

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.

2 Comments

Downvoters: please provide reasons, or your downvotes are somewhat pointless.
The downvote (not by me, I was checking your edit) was possibly because your statement (even after the edit) was slightly inaccurate. I see you've made things right now. It could be better put as "the ability to break directly via breakpoints is a new feature..."
1

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).

2 Comments

It's basically not nearly as well supported as it is in 2008. It's not as well integrated.
I would agree that to be considered "well supported" one would expect to be able to set breakpoints which 2008 now does. However to my knowledge (and I use it a lot) that is the only difference I've come across between the two when it comes to debugging.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.