Export (0) Print
Expand All

Client-Side Script Debugging Roadmap

This topic applies to:

Visual Studio

Visual Basic

C#

C++

J#

Visual Web Developer

Express

Yes

Yes

Yes

Yes

Yes

Standard

Yes

Yes

Yes

Yes

Yes

Pro/Team

Yes

Yes

Yes

Yes

Yes

Using the Visual Studio debugger, you can perform the following tasks when debugging client-side script in a Web page:

  • View the source code of the Web page (.htm, .html, .asp, .aspx) that you are debugging.

  • Control the pace of script execution with breakpoints and stepping.

  • View and change variable and property values with several debugging windows including the Immediate window and Watch window.

  • View and control script flow with the Call Stack window.

    NoteNote

    To debug script you must enable script debugging in Internet Explorer.

Viewing Source

When you work with the Visual Studio debugger, you see the script that you are debugging in a read-only editor in the IDE. You cannot change the text in the window; script documents are read-only while you are debugging. However, you can save the document under a new name, then open the document and modify it.

Controlling Program Execution

To control program execution, set breakpoints, which are places where the script halts execution. Lines containing breakpoints are highlighted in the editor.

After setting breakpoints, run the document containing the script. When execution reaches the first breakpoint, the script pauses and starts the debugger. The current line is marked in the editor with a yellow background and a yellow arrow in the left margin.

After reaching a breakpoint, you can step through individual lines in your script. As you step, the script executes and you can see the effect of each line.

If you reach a point in your script that calls another procedure, a function or subroutine, you can step into the procedure, or run, step over, it and stop at the next line. At any point, you can jump to the end, step out, of the current procedure, and out of it to the line following the original procedure call. You can also proceed to the next breakpoint.

Normally execution proceeds from statement to statement, and the procedures described above do not change this order, but merely affect the point at which execution will next break. However, you can also drag the yellow execution arrow to a different position and cause the line you leave it on to be the next statement to be executed. The only restriction is that you cannot change "scope": you cannot drag the arrow outside the current procedure.

Viewing and Changing Values

While debugging, you can view and change the values of variables or properties. Because you are making changes directly to a running script, you can affect the way that the script executes by changing values in it. After changing values, you can continue with the script and see the effect of your change.

To view and change values, you can use the Immediate window or the debugger Variable windows. You can evaluate any expression in the window and can enter script commands and see their effect. You can enter commands in the language of the script currently executing.

Viewing and Controlling Program Flow

The Call Stack window enables you to trace the procedures and functions that are currently executing. While debugging, you can view the flow of control from procedure to procedure. You can also select a procedure in the call stack and run until execution returns to that procedure. For more information, see How to: Run to a Specified Function.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft