Debug and explore AJAX with FireBug
AJAX, ASP.NET By Dave Ward on March 6th, 2007“where did you find documentation on the sender and event args objects in the PageRequestManager events?”
Lately, if I don’t hear that question at least a dozen times a week, I start worrying that something’s wrong with my contact form. I can understand why it would be a common question. The documentation we currently have for the JavaScript portion of the AJAX framework is on the light side.
The answer to the question is that I didn’t, but I can show you how I found what I did.
By using a JavaScript debugger, it becomes trivially easy to explore these objects and find out what makes them tick, even without formal documentation. Personally, I use FireBug for JavaScript debugging, so that’s what I’ll use to demonstrate. Any JavaScript debugger that allows you to set breakpoints will work though.
The code that I’m going to use for this example is my CSS style as AJAX progress indicator tutorial. With FireBug open (F12), I load up the tutorial in FireFox and click the script tab. Since my JavaScript is embedded in the page, I have to scroll down a bit, but it’s easy to find.
Let’s say I’m interested in learning more about the InitializeRequest event and how to find out the ID of the control that fired it. So, I’m going to set a breakpoint inside my InitializeRequest event handler, by clicking the left margin of the window beside a line in the handler:

With the breakpoint set, I click the submit button on my ASPX page. Since the breakpoint was in the InitializeRequest event, FireBug stops execution almost immediately. I’m given a JavaScript debugger with watches, breakpoints, and execution control very similar to what I’m used to using in Visual Studio:

Right away, I find what I was looking for: args._postBackElement.id contains a string with the name of the button that fired the event.
You can’t see it in the screencap, but there is a wealth of information in these objects. I would encourage anyone who is serious about ASP.NET AJAX framework development to take a few minutes and really dig through them this way. It’s hard to beat the power of learning by seeing and touching something, as opposed to just reading about it.
Don’t forget to also take a look at the PageRequestManager object itself. As the underpinning of the entire framework, it has some very useful methods and properties
I hope this helps you as much as it did me. If you have any questions, please don’t hesitate to post a comment or contact me.
Similar posts
What do you think? Your comments are welcomed.
I appreciate all of your comments, questions, and other feedback, but please try to stay on topic. If you have a question unrelated to this post, I recommend posting on the ASP.NET forums or Stack Overflow instead.
If you're replying to an existing comment, please use the threading feature. To do this, click the "Reply to this comment" link underneath the comment you're replying to.

Comments
You can debug java script with Visual Studio 2008. It’s fantastic. I’m using it to write javascript side of apps.