Friday, May 18, 2007

Q. How do I debug client-side javascripts in my ASP.NET application?

A. By enabling debugging in Internet Explorer and adding the "debugger" keyword to your javascript, like Walt Ritscher says to do in this blog entry:

http://waltritscher.com/blog/ramblings/archive/2004/09/19/211.aspx

Briefly:

  1. In Internet Explorer, go to Tools-->Internet Options-->Advanced, and uncheck the option marked "Disable Script Debugging"
  2. Add the word "Debugger" into your script where you want it to break into debug mode.
  3. Run the app. When the script hits that point, you'll be asked what you want to use to debug. Choose "New Instance of Visual Studio".
  4. Step through your code as normal.
That's it!

Updated to add:

This MSDN article has even more interesting things to say:

http://msdn2.microsoft.com/en-us/library/k2h50zzs(VS.80).aspx

0 comments: