Visual Studio ASP.NET projects allow you to set breakpoints
in either server-side or client-side code. However, when you start to debug,
the debugger does not stop at client-side breakpoints in the ASP.NET project.
↑ Back to the top
To work around this problem, follow these steps:
- Enable debugging in your browser. To do this in Microsoft
Internet Explorer 6.0, follow these steps:
- On the Tools menu, click Internet Options.
- On the Advanced tab, clear the Disable script debugging check
box, and then click OK.
- Insert a stop or a debugger statement in your client-side code. In Microsoft Visual Basic
Scripting Editing (VBScript), use the stop statement. In JScript, use the debugger statement.
The following code illustrates how to use
these statements in the OnLoad event:
'VBScript
Sub window_onload
stop
'Insert onload code here.
End Sub
//JScript
function window_onload() {
debugger;
//Insert onload code here.
}
When your browser reaches the stop or the debugger statement, the browser invokes the debugger (Visual Studio) to
enter debug mode. If you have multiple debuggers installed on the computer, the
browser prompts you to select a debugger.
After the browser invokes a
debugger, the browser displays the HTML page, which includes the client-side
code but not the server-side code. The browser stops in break mode on the stop or the debugger statement. - To set additional breakpoints in the code, click in the
gray margin to the left of any line of code.
- To set breakpoints that stop only under certain conditions
(conditional breakpoints), right-click on the breakpoint entry in the
BreakPoints window in Visual Studio .NET, and then click Properties.
↑ Back to the top
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
↑ Back to the top
Steps to reproduce the problem
- In Visual Studio .NET, create a new ASP.NET project.
WebForm1.aspx is created by default.
- When you open WebForm1.aspx in Visual Studio .NET, two tabs
(Design and HTML) appear at the bottom of the page. Switch to HTML
view.
- Add the following code to the Body section:
<script language="vbscript">
sub btn_onclick
btn.value = btn.value + 1
end sub
</script>
<INPUT type="button" value="0" id="btn">
- Set breakpoints in the client-side code. The btn_onclick procedure is client-side code. To set a breakpoint in this
procedure, click in the gray margin to the left of the following code:
btn.value = btn.value + 1
After you set the breakpoint, a red dot appears in the gray margin next
to that line of code. - In the Solution Explorer window, right-click WebForm1, and
then click Set As Start Page.
- Save your project.
- On the Build menu, click Build Project.
- On the Debug menu, click Start (or press the F5 key) to start a debug session.
- After the page appears in your browser, click the button.
Notice that the client-side code runs, but the debugger does not stop at your
breakpoint.
↑ Back to the top