Monday, May 17, 2010

How to debug Javascript & ASP

Writing alert in javascript and Response.Write in ASP to debug has been quite traditional. It just gives you an idea of the variable value runtime, what if
  • You want to frequently change the variable’s value on runtime to do some test
  • You want to step over or step into the function
  • There is a big variant (ASP) or object/Array (Javascript) and you just don’t know its dimension but want to see it all
There could be tons of reasons, you need a good debugging tool. I here tell you some simple tricks to ease your job.
Prerequisite: Microsoft Visual Interdev (comes with Microsoft Visual Studio 6.0)
Debug Javascript: By default, javascript debugging is disabled in browser. To enable it, Open IE, Go to
 Tools -> Internet Options -> Advanced -> Browsing
  1. Uncheck “Disable Script Debugging (Internet Explorer)”
  2. Uncheck “Disable Script Debugging (Other)”
  3. Check “Display a notification about every script error”
  4. Uncheck “Show friendly HTTP Error Messages”
Now whichever line you want to start debugging with in Javascript, just write keyword debugger before that and run your page.
What will happen next: You will be prompted with an error (“A runtime error has been occurred, do you want to debug?”). Now click Yes and choose visual Interdev to debug. You will find interpreter halted on your “debugger” line. Now you can debug it as you debug any other language. Cool Eh!!!
Debug ASP: VBScript is generally preferred as server side language in ASP. Like javascript, vbscript debugging is by default off in IIS. To enable it, Type inetmgr on run prompt, (it will open your IIS (web server) config) Now browse to your app directory under IIS Right click Go To
 Properties -> Configuration -> Debugging
  1. Check “Enable ASP server-side script debugging
  2. Check “Enable ASP client-side script debugging
Now whichever line you want to start with, write keyword stop before that. Now run your page.
What will happen next: You will be prompted with an error (“A runtime error has been occurred, do you want to debug?”). Now click Yes and choose visual Interdev to debug and Bingo!!! You can debug your ASP code like anything.

No comments:

Post a Comment