Debugging is one of the most important aspects of any application. In this article I will explain some neat tips and tricks about debugging using Visual Studio.NET.

Introduction:

Debugging is one of the most important aspects of any application. In this article I will explain some neat tips and tricks about debugging using Visual Studio.NET.

Don't follow the yellow brick road:

When debugging you don't really have to follow the "yellow brick road". This means that if you have to debug a page let's say "CustomerDetails.aspx" which only opens when you log in by going through the "Login.aspx" page then you don't have to login again and again if you don't want to. The idea is pretty simply open a browser which shows the CustomerDetails page now go to Visual Studio and start the debugging which will launch another browser window and most probably it will take you to the Login page since you have set the Login page as the default page. Now since the debugging is already in process you don't want to login to access the CustomerDetails page simply switch to CustomerDetails page which you have already opened in a new window and start debugging from there. This will save you lot of time since you don't have to go to the login page in order to debug your application.

Use break point conditions:

Have you ever tried to debug a loop that goes from 1 to 100. And the interesting thing is that you were only interested when the loop value was 68. One way is that you step into the code 67 times and finally the next value will be what you want. But this is far from a good practice. Luckily Visual Studio.NET allows us to place break point conditions. Simply place a break point on the condition where you want to break. After the break point has been set up right click on the break point and select condition. In the condition menu you can enter what is your break condition. If you want to jump into debugging when the loop value is 65 then simply enter i == 65, where i is the variable which is incremented for each loop. This is not only limited to integer values but also applies to complex values including DataSets and DataTable.

Debugging JavaScript:

JavaScript is very cool but the most annoying things about it is the debugging part. Most of the developers use popup boxes or alert boxes to debug the JavaScript. Visual Studio.NET 2005 as well as Visual Studio.NET 2003 provides the capability to debug JavaScript. Let's see how we can debug JavaScript in Visual Studio.NET 2005.

First make a small JavaScript function.

function Welcome()

{

var a = 10;

var b = 34;

var c = a+b;

}

This function is called when the HTML button is clicked.

<input type="Button" id="Mybutton" value="Press me" onclick="Welcome()" />

Now select the debug menu from the top and click on "Attach a process". A window will open with all the currently running processes you should select iExplorer.exe. After your process has been attached you need to run the application in a debug mode and then fire the JavaScript event by pressing the html button. After you have fired the event go back to the Visual Studio editor and from the Debug menu select Windows and Script Explorer. When you see the script explorer you will also see the file which you are executing. Simply click on the file and it will take you to the html view of the page where you can add the break points in the JavaScript code. Once break points are added simply click on the HTML button again and this time it will debug the JavaScript.

Moving arrow up and down:

Did you know that you can put the debug arrow anywhere in your application? I am talking about the yellow arrow that appears on the left hand pane when you are in the debugging mode. This is fairly useful when you want to debug a certain line and you accidentally passed that line during debugging. In this situation you can simply drag the arrow up and place it on the line that you wish you debug.

hope you liked this article, happy coding!

If you are one of the thousands that visit GridViewGuy for your .NET articles and resources, you might be interested in making a donation. Extra cash helps pay for the hosting services and speed things up around here, and makes this website possible.

Make a Donation

Once, again thank you very much and remember its because of you FINE people that this website is up and running.

 

Export Button is a custom control that let's you export your DataGrid or TextBox data to several different formats. The control is extremely easy to use and also exposes design time features. In this article I will discuss some of the features of the Export Button and how it benefits the developer.

BUY IT NOW