Debugging JavaScript with ASP.NET Ajax, FireFox and FireBug

An entry about tools | javascript Publication date 8. September 2007 16:19

Debugging JavaScript used to be stupidly difficult. Ever littered your script with alert() statements in a vain attempt to figure out what the hell is going on? I know I have. One thing the ASP.NET Ajax framework includes to help ease debugging is a very handy class called Sys.Debug, which has got exactly what you'd expect it to have - methods for tracing.

Now, the cool thing is how this works together with FireFox and the FireBug plugin - any Sys.Debug.trace() or Sys.Debug.traceDump() calls gets written directly to the console. For example, the lines:

Sys.Debug.trace("Calculating bounds...");
var bounds = Sys.UI.DomElement.getBounds(element);
Sys.Debug.traceDump(bounds, "Bounds");

shows up like this:

image

Neat!

The FireBug plugin also supports breakpoints and lots of other great stuff. Maybe I'll blog about some of its features in a future post - it is definitively one of my favorite tools when working with client-side code. And I know, I know - Visual Studio 2008 gives us a lot of this stuff integrated into the development IDE - but that only works with Internet Explorer (at least for now).

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.


Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS