Visual Studio 2008: Debugging JavaScript in a UserControl

In Visual Studio 2008, you can not set a break point within a usercontrol / .ascx. But you can still debug your JavaScript code.

Make sure you uncheck Disable Script Debugging in Internet Explorer. Add the word debugger within your JavaScript code. Run the page and it will hit debugger line and prompt you with either the Built-In Debugger or you can use Visual Studio IDE. Now you can step through your code.

[codesyntax lang=”java”] function ValidateClientSizeComment() {
debugger
var clientSizeComment = document.getElementById(“<%= txtClientSizeComment.ClientID %>”).value.length;
if (clientSizeComment >= 50) {
var myVal = document.getElementById(‘<%= cvClientSizeComment.ClientID %>’);
ValidatorEnable(myVal, false);
}
}
[/codesyntax]
Click Here to Leave a Comment Below 0 comments

Leave a Reply: