Client-Side Script Debugging
This topic applies to:
Edition |
Visual Basic |
C# |
C++ |
Web Developer |
---|---|---|---|---|
Express |
||||
Standard |
||||
Pro and Team |
Table legend:
Applies |
|
Does not apply |
|
Command or commands hidden by default. |
The Visual Studio debugger provides a comprehensive debugging environment for finding and correcting errors in your Web document scripts. You can use the Visual Studio debugger to test scripts written in VBScript or JScript. Visual Studio supports debugging of client-side scripts in ASP.NET pages.
Enabling Script Debugging
Before you can begin debugging script with Visual Studio, script debugging must be enabled in Internet Explorer. For more information, see How to: Enable and Start Script Debugging from Internet Explorer.
Opening Script Documents
In Visual Studio 2008 you can view use Solution Explorer to view lists of server-side and client-side script documents. You can open any script document from Solution Explorer. For more information, see How to: View Script Documents.
Breakpoint Mapping
In Visual Studio 2008, you cannot directly debug server-side code, but you can set a breakpoint in a server-side file. Visual Studio automatically maps the breakpoint to a corresponding location in the client-side file and creates a mapped breakpoint in the client-side code. For more information, see How to: Set Breakpoints in Script.
Breakpoint mapping is subject to certain limitations. For more information, see Limitations on Script Debugging.
Manually or Automatically Attaching to Script
To begin debugging script in Visual Studio, the debugger must attach to the script you want to debug. This can happen manually or automatically.
You can manually attach by using the Visual Studio debugger interface to choose a running script process you want to attach to. For more information, see How to: Attach to Script.
The debugger automatically attaches to script when one of the following things occurs:
You hit a breakpoint set in script. For more information, see How to: Set Breakpoints in Script.
You hit a VBScript Stop statement or JScript debugger statement in your script code.
The browser or server encounters a syntax or run time error in your script. When this occurs, a dialog box appears and have the option to begin debugging.
You use the Internet Explorer Script Debugger menu to begin debugging. For more information, see How to: Enable and Start Script Debugging from Internet Explorer.
When you manually attach to script, the script process continues to run until it is somehow halted. You can halt it by choosing Break on the Debug menu.
When the debugger attaches automatically, script execution is halted at the line where the breakpoint, Stop statement or debugger statement, or error occurred, or at the point where you chose to start debugging in Internet Explorer.
At that point, you can use the normal debugger facilities to begin debugging. For example, you can use Step commands to continue to execute your code line by line. You can use the Call Stack window to view and control script flow. You can use the variable windows or Immediate window to view or change variables and properties.
Enhanced Error Messages for Script Debugging
Visual Studio provides enhanced error messages for common script debugging problems. These messages do not appear unless you attach to Internet Explorer manually. If you encounter an error condition when Internet Explorer is opened automatically, try manually attaching so that you can see the error messages.
Debugging AJAX Script Applications
AJAX-enabled Web applications make heavy use of script code and pose special debugging challenges. For information about AJAX debugging techniques, see
Debugging and Tracing AJAX Applications Overview.
See Also
Tasks
How to: Enable and Start Script Debugging from Internet Explorer
Concepts
Debugging and Tracing AJAX Applications Overview
Reference
Limitations on Script Debugging