C Programming Tutorials and advice
CProgrammingTrends News Archives About Us Feedback

Recent Articles

From VB.NET To C#
Coming from the Visual Basic world, I used to find many examples throughout the web written in VB and VB.NET. Then I got hired by Traceworks which was a VB.NET company, but they decided to move to C# because...

Bind Countries From CultureInfo Class In C#
Some people have asked me how BlogEngine.NET displays a dropdown list of countries when no source XML file is present. The simple answer is that you don't need any external list to bind to from C#, you can instead...

See Who Calls Any Method In C#
In some situations it can be important to know which methods are calling other methods. Think of an error log. Here you would like to know which method that threw the error and at what line in what file. This helps to debug runtime code and makes it very...

Compress & Decompress Strings In C#
A couple of days ago, I had to store some very big strings in an XML file. To keep the file size down I wanted to compress the strings using a GZipStream and then decompress them later when needed. I modified...


06.28.07


Debug JavaScript In Visual Studio 2005 Like C#


By Mads Kristensen

I've been using Visual Studio 2005 for almost 2½ years since the beta 1 release.

In all that time, I've used Firefox and Firebug for all JavaScript debugging. I've tried setting breakpoints in JavaScript in Visual Studio before, but I never got it working so I left it for Firebug. Then the other day, our new developer at Traceworks told me that Visual Studio could be used for debugging and that it is possible to set breakpoints in the JavaScript files.

This of course illustrates that I'm slow - 2½ years slow to be exact. For those of you, who are as slow as me, keep reading and I'll tell you how to debug JavaScripts in Visual Studio.

Set up Internet Explorer

Internet Explorer has disabled the possibility to debug scripts by default, so the first thing to do is to enable it. In the top menu, go to Tools -> Internet Options -> Advanced. Here you need to remove the checkboxes in Disable script debugging.

This is needed for Internet Explorer to tell Visual Studio about the JavaScript running in the browser.

Process credit card payments anytime, anywhere.
Go Wireless! Click Here for full details.

Start debugging

In included .js files you are now able to set break points as you normally would in C# or VB.NET. The execution stops at the break point and you are able to see the values of the variables and to move forward by hitting F10 and F11 like normal. The experience is exactly the same as debugging C# code.

For inline JavaScript you cannot set break points, but Microsoft did provide us with an alternative. If you add the word debugging wherever you want in the script code, the execution will stop at the word and you can debug exactly the same way as setting a break point.

For this to work, you must run Visual Studio in debug mode. That's it, extremely powerful and easy to do. The only thing I don't like about this is that I didn't know about it before now. C'est la vie.

Comments

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

About CProgrammingTrends
A collection of articles and tutorials designed to help C and C variant programmers in their programming work. C Programming Tutorials and advice

CProgrammingTrends is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagmentNews.com


-- CProgrammingTrends is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal


archives | advertising info | news headlines | free newsletters | comments/feedback | submit article




CProgrammingTrends Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact