views:

420

answers:

4

In this very simple ASP.NET application, Visual Web Developer 2008 Express CAN debug the Javascript 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 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"&gt;

<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.");
}
+1  A: 

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.

Jon Skeet
Downvoters: please provide reasons, or your downvotes are somewhat pointless.
Jon Skeet
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..."
Cerebrus
Okay, will edit in that respect.
Jon Skeet
A: 

JS debugging is a feature of VS2008 it simply does not exist for VS2005 : )

Edit: I have relied on Firebug for JS debugging while using VS2005. Just saw the great points made by Edward and will be looking into it..

kaivalya
+4  A: 

Hi Edward,

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.
rAm
Cool - although it's obviously a lot simpler to just use the integrated version in VS2008 :)
Jon Skeet
I agree, life is simpler in VS 2008. Also another thing I personally prefer is to use a browser based debugger (firebug/firefox)
rAm
+1  A: 

To be clear VS 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 VS 2005 you can place the debugger directive in the JS 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).

AnthonyWJones
It's basically not nearly as *well* supported as it is in 2008. It's not as well integrated.
Jon Skeet
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.
AnthonyWJones