Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Mindcracker MVP Summit 2012
Search :       Advanced Search »
Home » Visual Studio .NET » Debug Client Side Script in Visual Studio 2005

Debug Client Side Script in Visual Studio 2005

This article is for web developers, because it's target is one of the new feature in Visual Studio 2005 which is debug client side script.

Page Views : 24626
Downloads : 0
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Discover the top 5 tips for understanding .NET Interop
Become a Sponsor
DevExpress Free UI Controls
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 


Introduction

Visual Studio 2005 is shipped with a lot of new features for all developers. If you are windows, web or distributed application developer, you will be happy to the see the added new features in VS 2005.

This article is for web developers, because it's target is one of the new feature in VS 2005 which is debug client side script.

Visual Studio 2005 is shipped with built in "Client Side Debugger" which simplifies the debugging process in web application rather than use the traditional alert techniques to debug your JavaScript code.

Prerequisites

Applies on: Visual Studio 2005

Overview

Any business web application doesn't free of set of .js files which contains a lot of JavaScript functions, which implement business validation and verification on the business rules on the web application it self.

Most of developers in VS 2003 use the traditional techniques to validate their java script code, like using alert message to show the current result if it's follow the validation required or not.

In VS 2005 has built in Java script Debugger, and what you need is just write your java script function and run the debugger by writing one line of code.

We will start by building simple web site which contains 3 input fields and a button to divide the values of 2 numbers and output it in a result field.

A screen shot of the page.

clientscript1.gif

Once you write the 2 numbers and click divide button, it will call client side function to divide 2 numbers.

Screen shot of the HTML of the page.

<table>

   <tr>

      <td width="100">

<asp:label id="lblFirstNumber" runat="server" Width="125">

   First Number:

</asp:label>

      </td>

      <td width="50">

<input id="txtNumber1" type="text" maxLength="3"

   size="5" name="txtNumber1">

      </td>

    </tr>

    <tr>

      <td width="100">

<asp:label id="lblSecondNumber" runat="server" Width="125">

   Second Number:

</asp:label>

      </td>

      <td width="50">

<input id="txtNumber2" type="text" maxLength="3"

   size="5" name="txtNumber2">

      </td>

     </tr>

     <tr>

       <td width="100">

<asp:Label id="lblResult" runat="server" Width="125">

    Result:

</asp:Label>

</td>

<td width="50">

  <input id="txtResult" type="text" size="5" maxlength="5"

     NAME="txtResult" readonly>

</td>

      </tr>

    </table>

    <br>

    <table>

   <tr>

      <td width="150" align="center">

        <input id="btnDivide" onclick="return btnDivide_Clicked()"

          type="submit" value=" Divide " name="btnDivide">

      </td>

   </tr>

</table>

The code of the JavaScript function is:

function btnDivide_Clicked()

   {

       var intNumber1 = 0;

        var intNumber2 = 0;

        var intResult = 0;

       

        debugger

                            

        intNumber1 = document.all('txtNumber1').value;

        intNumber2 = document.all('txtNumber2').value;

        intResult = intNumber1/intNumber2;

        document.all('txtResult').value = intResult;

        return false;

    }

</SCRIPT>

It's simple JavaScript function, the keyword debugger is used by .Net IDE to run the Script debugger.

View the page in the browser, the script debugger will run.

clientscript2.gif clientscript3.gif

Select the Script editor, as below figure shows:

clientscript4.gif

Then the script editor opens and then you can work and validate the validation through adding your variables on the watch.

clientscript5.gif
You can use F9 and F10 to go line by line for your code.

After return statement you will return to your page with the result. 

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Moustafa Arafa
Moustafa Arafa, DotNet Boom supportive development manager, I have MCAD.Net, MCSD.NET, MCT & C# MVP. I have passion to learn new technologies & to share my knowledge and experience with others. contact me : http://moustafa-arafa.blogspot.com/
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Nevron Chart
Become a Sponsor
 Comments
You have to enable Client side debugging in IE by Moustafa On May 20, 2006

 

You have to enable client side debugging on IE :

 

Tools --> Internet Options --> Advanced Tab --> un check for disbale client side debugging.

 

Reply | Email | Modify 
New Feature? by Michael On May 29, 2006
This is not a new feature.  This was available in VS2003 and before .Net in InterDev.
Reply | Email | Modify 
Re: New Feature? by Moustafa On December 24, 2006
thanks,it's there but it has been enhanced.
Reply | Email | Modify 
Re: Re: New Feature? by srinivas On November 19, 2009
Nice article Moustafa, about how to debug javascript in vs2005 step by step with figures.
Reply | Email | Modify 
DevExpress Free UI Controls
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.