Introduction
When an ASP.NET developer uses jQuery or JavaScript (clientside programming) in his code, the question always arises of how to debug this code. We can debug in code behind with breakpoints. But what for clientside scripting. Some people say use "alert()", but I don't think this is a sufficient way to do it.
So the good news is that we have "debugger". Use debugger before your code, where you want to start debugging.
Using the code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function () {
$(
debugger;
//Get the value of Radio button
var _GetVal = $(this).attr(
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
First
<input type="radio" name="rd1" value="10" />
<input type="radio" name="rd1" value="11" />
Second
<input type="radio" name="rd1" value="12" />
<input type="radio" name="rd1" value="13" />
</div>
</form>
</body>
</html>
This is a simple ASP.NET in page code. When the user clicks a radio button, debugging will automatically start, due to the debugger command. In the above program, when the user clicks on the radio button we stored its value in the _Getval variable.
$(document).ready(function () {
$(':radio').click(function () {
debugger;
var _GetVal = $(this).attr('value');
});
});
When you click in any radio button , automatically your debugging will start.
So with the use of the debugger you can start your debugging in ASP.NET.
And please remember, when you finish debugging or publish your page, please remove debugger from your code.
If you have any query, Please send your valuable Comments. Happy Programming.