Monday, March 24, 2008

JavaScript Debugging in Visual Studio 2005

We all know that "JavaScript Debugging" is one of the hottest feature of newly launched Visual Studio 2008 by Microsoft. In that we can add breakpoint and check the values in JavaScript in watch window at runtime also. Also Microsoft has added Intellisense for JavaScript. So indirectly..Life is much more simple now..Thanks to Microsoft for that..!! ;-)

Well..But what about Visual Studio 2005??..I am still using it..rather me and many of my friends like you people are using it.

Just we need to do set-reset some settings and we can also Debug JavaScript in Visual Studio 2005. I know very well that its not full fledge Debugging, but atleast you can see that its going to debug mode in your script and you can check values by selecting them and pressing Shift+F9 we usually do.

For this, First step is Start Internet Explorer, Go to "Tools" Menu, Click on "Internet Options", A wizard kind of Window will get open in front of you, Here you will see some 6-7 Tabs. Click on "Advance" Tab which is in last position. On clicking Advance Tab you will find some Tree like Categorized options with CheckBox to select-deselect it.

So under "Browsing" Category you can see on option check by default as "Disable Script Debugging (Internet Explorer)" , Uncheck this option if it is checked (Generally it is a checked option by default)

Now move to Visual Studio and just add a word "debugger;" in your script and run that..you done with it, Once that Javascript will get fire, you will automatically get thrown in HTML Code window where you have written JavaScript.

Function HelloWorld()

{

    debugger;

    alert('Hello User !');

    ....

}

You can see that you can break through it with F10 step by step and watch values of variables if any inside it. I know though we are not able to add breakpoint physically in Visual Studio 2005, but this may help a lot.

Being a Web Developer by profession, I know how much pain my developers friend they suffer from each day just because they can't debug script like they debug their VB or C# code.

This one I tested on Internet Explorer 7 and its working well, As I don't have IE6 and I don't have SP for Vista so indirectly I don't have IE8 too..So I will try to check out this on both of them soon and will get back to you..between I am also trying hard to run this on Mozilla ;)

Vikram.

Thursday, March 13, 2008

Simple LINQ Demo

Everyone here now must be aware of the revolutionary model of Data Connectivity and Data Handling. I just saw few days ago some articles posted on Internet but for newbie like me who are just came out from college in such big Developer community. Its very difficult to judge these days what to learn, when to learn and from whom to learn..isn't it..? ;-)

I was shocked firstly when I saw few Videos and Articles on LINQ , I done lots of C programming in My MCM Course for more than a year, but I never query any collection or string. I think future is bright for Data Connectivity, Right now I everyday have debate in my company over the MVC (Model View Controller) pattern of Data connectivity, Some says its quite slow because of many internal trips in Classes, Some says its the only best, but what I observe is Web Service is superfast!!

Humm..And one last thing..Don't try this on Visual Studio 05 ;-) .. This VS08 is awesome!!

Where here my code goes which is basically a C# console application, I can say that these code snippets can fall under category of LINQ to Objects, I am using IEnum

Make sure before you start coding that you have following namespace included

System.Linq and System.Linq.Expressions

static void Main(string[] args)

{

string[] friends = { "Vikram", "Chaitanya", "Ameya", "Sid" };

//Normal declaration of string which contains few names for example

//Below is Query which we are executing over our pre-defined collection

IEnumerable<string> firstname = from v in friends

where v.Contains("i") && v.Length <7

orderby v ascending

select v;

//Below is plain simple loop which will just print the query result

foreach (string name in firstname )

{

    Console.WriteLine(name);

}

//Still I am not forgetting getch() in C

Console.ReadLine();

}

Some of the query combination you can try on with && and || operator

  1. Using "And" operator i.e &&

    IEnumerable<string> firstname = from v in friends

where v.Contains("i") && v.Length <7

orderby v ascending

select v;

  1. Using "Or" operator i.e ||

    IEnumerable<string> firstname = from v in friends

where v.Contains("i") || v.Length <7

orderby v ascending

select v;

Well..I hope this will give some idea how LINQ looks like..will do now LINQ to XML soon.

Vikram.

Sunday, March 9, 2008

Implementing Ajax : With UpdateProgress

This is simple method to apply Ajax to contents of webpage, It may be some control or maybe some DataGrid or whole page, With Update Panel, you just need to drag and drop UpdateProgress Control which generally comes with ASP.NET AJAX Toolkit.


 

You can add any image to UpdateProgress in its <processtemplate>, Generally we see such "Loading.." image on many sites, Below code will help you to archive this.


 

Well you still need to do some trail to exactly position that Image on the location where you want. This can be done by setting Absolute Position of Image.

<asp:ScriptManager id="ScriptManager1" runat="server" EnablePartialRendering="true" >

</asp:ScriptManager>

<asp:UpdatePanel id="UpdatePanel1" runat="server" >

<contenttemplate>

</contenttemplate>

</asp:UpdatePanel>

<br />


 

<asp:UpdateProgress EnableViewState="true" ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server" DisplayAfter="1">

<ProgressTemplate >

<DIV id="progress">

<IMG style="LEFT: 540px; POSITION: absolute; TOP: 180px" alt="" src="Imgages/ajax-loader.gif" />

</DIV>

</ProgressTemplate>

</asp:UpdateProgress>


 


 

You can download more AJAX images at http://www.ajaxload.info/


 

Vikram.