Reputation: 2691
I have simple javascript function:
<form id="form1" runat="server">
<script type="text/javascript">
function doSomething(message) {
var div1 = document.getElementById('div1');
div1.innerHTML = 'afas';
}
</script>
<telerik:RadButton ID="btnShowUpload" runat="server" OnClientClicked="doSomething('test1')" Text="Upload file">
</telerik:RadButton>
When I set breakpoint in function OnClientClicked and start by F5 and then click button, application doesn't stop at breakpoint. It only stop when I run my project by Start without Debug and then in Mozilla (firebug) I can set breakpoint in this function and it stop when I press button. How to debug in Visual? not in Mozilla ?
Thanks
Upvotes: 1
Views: 4920
Reputation: 3919
you can set in your javascript a breakpoint with debug instruction -
function OnClientClicked(button, args) {
debug;
if (window.confirm("Are you sure you want to submit the page?")) {
button.set_autoPostBack(true);
}
else {
button.set_autoPostBack(false);
}
}
Upvotes: 0
Reputation: 44931
Right-click on a page in your project, such as Default.aspx, and select the Browse With... menu item.
When the dialog is displayed, select Internet Explorer, then click the Set As Default button, then press the cancel button.
Open internet explorer, go to the Internet Options dialog, click on the Advanced tab and ensure that under the Browsing section, Disable script debugging (Internet Explorer) is NOT checked.
Then, to force debugging, you can add the javascript debugger; line to the body of your javascript method:
function doSomething(message) {
debugger;
// rest of your code
When you debug this way, internet explorer will give you the ability to select which application and instance to use and one of the options will be internet explorer.
There are also other ways to attach the debugger to an instance of internet explorer from within a Visual Studio web application project, such as selecting Attach To Process... from the Debug menu and selecting the instance of iexplore.exe that has a type of Script listed in the type column and that is running the page you are interested in debugging.
Upvotes: 2
Reputation: 3274
Place the debugger keyword before the java script code you want to debug.
<form id="form1" runat="server">
<script type="text/javascript">
//enable debugging javascript code
debugger;
function doSomething(message) {
var div1 = document.getElementById('div1');
div1.innerHTML = 'afas';
}
</script>
Upvotes: 0