Hi,
How to debug java script code in asp.net with respect to internal page(.aspx) and external reference file(.js).
Also i need to know, how to catch java script errors in log file in visual studio...?
Thank You.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anand UchagawkarPosted Nov 28, 2013, 10:14 AM
Answer 1 - Debug in VS
Visual Studio has inbuilt capability to debug the aspx content and js files as well. You just need to put the proper breakpoint as you do for the codebehind.
If you do not want VS to debug then there is inbuilt alternative in IE8+. You have IE developer toolbar present in the options (or press F12). From that you can go to Script Tab > Start Debugging > Put breakpoint once your page is loaded
Answer 2 - Log in Javascript
You should understand that javascript is a Client side code so it does not have feature to log errors on the client end.
But even though if you want to log the errors, then you can follow these steps (Note- Following approach can be used only for logging handled errors)
1. Write a web method or Web Service which can be called through Javascript
2. In the javascript catch block call the Web Method or the Web Service Method and pass the error content
3. Log the error content in the server side code.
Hope this helps.
Kunal VaishyaPosted Nov 28, 2013, 6:07 AM
In Simple way