Localization and Globalization in ASP.NET Handling Exceptions in JavaScript
Jan 05

Hello everyone, I was really excited to do this second video tutorial because I got some good reviews on the first one and I’ll do my best to make this even better.

On the next tutorials I’ll be talking a lot of about JavaScript, so I thought it would be a good idea to show how we can debug JavaScript in Visual Studio. Because in my personal opinion debugging is the best thing you can do in order to find errors in your application. It’s really easy and this video won’t be longer than 5 minutes.

Let’s start:

We are going to use the solution that we created for the first video tutorial, we need to add a new website and give the name as Debugging-JavaScript-in-Visual-Studio, we also need to add a new item which is a JavaScript file and give the same name as Debugging-JavaScript-in-Visual-Studio.

On the Default.aspx page we need to add the JavaScript file:

<script language=”javascript” type=”text/javascript”
src=”Debugging-JavaScript-in-Visual-Studio.js”> </script>
     

On the body tag:

<body onload=”CallSomeMethod()”>

On the JavaScript file:

function CallSomeMethod()
{   
  var a = 10;  
  // b is undefined;   
  c = a + b;
}
     

This will generate an error, let’s pretend we don’t know that, so then, you can say that you can notice the error, you don’t need to debug, but imagine a bigger or more complex application, in this situation can be hard to find an error, so debug is the best option you have.

If we run the application now and try to debug you will see that nothing is going to happen, instead of that the browser pops up the error message.

Error Message

So, don’t you think it would be awesome if we have the feature to debug JavaScript, actually we have, and all we need to do is enable it.

5 Steps to enable debug JavaScript in Visual Studio

1- Open the Internet Explorer;

2- Go to Tools;

3- Click on Internet Options;

4- On the Tabs on the top, go to Advanced;

5- On the Browsing section, uncheck the two options that say “disable script debugging” (Internet Explorer) and (Others);

Now if we run the application again you can see the Visual Studio is able to debug our JavaScript code, show the variables values, in the same way it does for any other normal ASP.NET application.

That’s all you needed to do and know, thank you very much. I hope you have enjoyed.

To download the code, click here -> Debugging JavaScript in Visual Studio.NET

Author: Luciano Sampaio

12 Responses to “Debugging JavaScript in Visual Studio.NET”

  1. Steph Says:

    Hey Luciano, even though I have no technical background, your writing and instructions are clear enough for me to understand and follow! Great job!

    Oh, and thanks for your “Just for Fun” page (after some learning I needed a laugh). Just one thing though: I would love to leave a comment or two about the videos. Is there a way to offer this option?

    Thanks for your hard work and knowledge!

  2. Afshin Mousavian Says:

    Mr. Luc, Wow these tutorials are awesome. Talk about taking the extra step, you do an outstanding job of explaining the details in the videos and also adding the information on the page. This is great.
    I was just wondering if you are able to similar debugging for php. Because some of my php scripts have some glitches, but it takes me a long time to try and figure them out. Do you have any suggestions??

    Thanks,

  3. TheCodeMaster Says:

    Hi Steph, Thank you for your comment, i found a wordpress plugin that allows you to add a contact form on any page, I’ll add it to the Just for FUN, ok!!

  4. TheCodeMaster Says:

    Hello Afshin, Unfortunately Debugging PHP is not that straightforward as any of the .NET languages, but I ran a quick search and I found a very nice article that I would suggest you to read : http://www.ibm.com/developerworks/library/os-debug/. Thanks for you comment!!

  5. Darius Bashar Says:

    How long have you been making video tutorials for? You are so quick and accurate it is amazing what we can do and learn through the Internet. Now you got my juices running I am not as technical as you are but I know there are a lot of lessons I can teach to the readers of my blog through such a technology.

    Great job Code Master!

  6. TheCodeMaster Says:

    Thank you Mr. Darius!! I just started a couple months ago and I’m still trying to make it a habit to blog every day, but due my English accent it’s taking me more than what I wanted to post any new tutorial. I’m pretty sure that you have a lot of things to teach, and doing that you’ll have the AMAZING felling of been helping other people.

  7. Thiers Says:

    luciano,

    Congratulations about your new blog and i´m sorry about my poor english :). The tutorial videos help us programmers to do simple things. A sugestion for you make a tutorial is about AJAX components. I know thath you are Phd in this job.

    Regards,

  8. David Newton Says:

    Hi Luciano,

    That is very helpful and interesting for a junior and intermediate programmer. I would like to know how you made such high quality videos. The turorials are great. very easy to understand. I learned a little more about TRUE FALSE handling.

    Dave

  9. TheCodeMaster Says:

    Hi Thiers, Thanks for your comment, but the thing is I already have prepared some tutorials, that i think it will teach starting from the basic to more complex examples, so I will talk about AJAX but before that I have to explain some basic stuff. ok thanks!!

  10. Igor Says:

    Hi my super brother, congratulations for your page.You are the guy man!!!Simple but very very usefull.See you shortly

  11. Luciano Sampaio Says:

    Igor, my super friend, THANKS for you comment!!!

  12. visual studio tutorial Says:

    [...] JavaScript in Visual Studio.NETThis guy is a pro! I can’t wait for his next video tutorial!http://thecodemaster.com/javascript/debugging-javascript-in-visual-studio/Visual Studio Tutorial - Make Application Beep on TechnoratiNet Framework and the C programming [...]

Leave a Reply