Remote Desktop with Dual Monitors

I recently came across this, find it very useful and productive at work. If you are using dual monitors, could use the same when doing a Remote Desktop. To use Remote Desktop for dual monitors, type

mstsc /span


and run in the command prompt. There are few limitations in using this though, you can find them here in MSDN blog.

This works in Remote Desktop client V6.0 or higher which means having Vista is ok, Windows XP users might have to update their client. The RDP client could be updated from here


I use a lot of saved RDP connections, in fact have a RDP folder in the Taskbar. If that’s the case, open the *.RDP file in notepad and add this line at the end

Span Monitors:i:1


And finally if you are using SplitView, it supports Remote Desktop with Dual Monitors which means it will take care of resizing windows within monitor and other features for you, otherwise you will have to resize windows manually.


BlackBerry JDE and source control Vault integration

I have been developing applications for Blackberry recently using Blackberry JDE in Java. I have always used Vault for source control in Visual Studio and it integrates well with Visual Studio. Here is how to do it in BlackBerry JDE.

BlackBerry JDE supports source control integration as you can see in this screenshot

BlackBerry JDE Source Control Preferences

The tricky bit is to setup the vault command in there. SourceGear Vault has a command line tool “Vault” which could be used. Here is the usage of it,

Vault Command Usage

Here is checkout command usage,

Vault Checkout Command Usage

Now enable source control integration and setup appropriate appropriate commands for checkout, revert and add file for source control in preferences dialog of BlackBerry JDE as shown below

BlackBerry JDE Source Control Preferences - Vault

Checkout Command:

vault checkout -host -user yourusername -password yourpassword -repository “Repository name” %1

Revert Command:

vault undocheckout -host -user yourusername -password yourpassword -repository “Repository name” %1

Add File Command:

vault add -host -user yourusername -password yourpassword -repository “Reporsity name” -commit repositoryfolderpath %1


After you setup these, make sure to setup vault command in path variable for your PC so the JDE picks it up. As for Vista, goto Computer –> Properties –> Advanced System Settings –> Environment Variables as show below,
Environment Variable Settings Vista

Vault Command Path:

C:\Program Files\SourceGear\Vault Client


That’s it, you are all set to go. The JDE with Vault will work fine now. The only problem I found is the inability to checkin files and to specify dynamic repository path in add script from within the JDE, will update the post once I find some info on that.


ASP.NET Charts – Storage Mode

Microsoft has released charts for ASP.NET few weeks back at the PDC. ScottGu has blogged about it here. I have been using charts in the past from a third party vendor and have converted them all to ASP.NET charts because of the variety & extensibility they provide and it will be part of .NET Framework 4.0 moving forward even though it’s a separate installation now . It was acquired from Dundas Charts by Microsoft.

One thing I could not find in the documentation is a way change the location where chart is stored. By default it’s stored in hard disk and the location is specified in the web.config file as below

  1. <appSettings>  
  2.     <add key=“ChartImageHandler” value=“storage=file;timeout=20;dir=c:\TempImageFiles\;”/>  
  3. </appSettings>  

 Many times, the chart image generated might differ from user to user. In those kind of scenarious it’s better to store the chart image in the memory.

  1. <appSettings>  
  2.     <add key=“ChartImageHandler” value=“storage=memory;timeout=20;dir=c:\TempImageFiles\;”/>
  3. </appSettings>  

And lastly the chart image could even be stored in session if required,

  1. <appSettings>  
  2.     <add key=“ChartImageHandler” value=“storage=session;timeout=20;dir=c:\TempImageFiles\;”/>
  3. </appSettings>  

But make sure you use “out of proc” mode for session for this to work.


Silverlight 2 RTM Releasing Today

Microsoft has announced yesterday that Silverlight 2 will be releasing today. You can check the announcement here in Microsoft’s press release

Microsoft Releases Silverlight 2

Silverlight -plugin with a download size of only 4 MB provides rich support to video stream and works on most of the browsers in Mac, Windows & Linux.

You could listen to ScottGu’s teleconference here

ScottGu’s Teleconference

ScottGu shares information like how Silverlight was used by NBC for 2008 Olympic Games and statistics of the same. He also answers many questions like Silverlight’s support in Mobile, iPhone and Chrome etc..

Silverlight 2 includes the following features, 

.NET Framework support with a rich base class library. This is a compatible subset of the full .NET Framework.

Powerful built-in controls. These include DataGrid, ListBox, Slider, ScrollViewer, Calendar controls and more.

Advanced skinning and templating support. This makes it easy to customize the look and feel of an application.

Deep zoom. This enables unparalleled interactivity and navigation of ultrahigh resolution imagery.

Comprehensive networking support. Out-of-the-box support allows calling REST, WS*/SOAP, POX, RSS and standard HTTP services, enabling users to create applications that easily integrate with existing back-end systems.

Expanded .NET Framework language support. Unlike other runtimes, Silverlight 2 supports a variety of programming languages, including Visual Basic, C#, JavaScript, IronPython and IronRuby, making it easier for developers already familiar with one of these languages to repurpose their existing skill sets.

Advanced content protection. This now includes Silverlight DRM, powered by PlayReady, offering robust content protection for connected Silverlight experiences.

Improved server scalability and expanded advertiser support. This includes new streaming and progressive download capabilities, superior search engine optimization techniques, and next-generation in-stream advertising support.

Vibrant partner ecosystem. Visual Studio Industry Partners such as ComponentOne LLC, Infragistics Inc. and Telerik Inc. are providing products that further enhance developer capabilities when creating Silverlight applications using Visual Studio.

Cross-platform and cross-browser support. This includes support for Mac, Windows and Linux in Firefox, Safari and Windows Internet Explorer.

I will be blogging more about Silverlight in the coming days.


jQuery Cheat Sheet

Scott has created a nice cheat sheet that has all the functions related to jQuery in one page. You could download it from here and print it for quick reference. It’s very handy rather than going to JQuery help.

Sortable GridView using jQuery’s TableSorter


This blog post explains how to use jQuery’s plugin Tablesorter to implement client side sorting in ASP.Net Gridview. This comes in handy especially when object data source is used with grid view as gridview does not provide sorting out of the box


To implement TableSorter, the rendered table should have THEAD in the markup. Gridview does not provide this by default but we could achieve it either by setting appropriate properties or by using a CSS friendly control adapter. We will do it by using the former method.


You could have a look at it online here

Using the code

We should get the table with THEAD tags for the gridview to implement the sorting. So, lets do that

  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (this.gvEmployees.Rows.Count > 0)
  4.         {
  5.             gvEmployees.UseAccessibleHeader = true;
  6.             gvEmployees.HeaderRow.TableSection = TableRowSection.TableHeader;
  7.             gvEmployees.FooterRow.TableSection = TableRowSection.TableFooter;
  8.         }
  9.     }

If you are using grid view in update panel and binding it in a call back, then it’s better to put it in gridview’s databound event,

  1. protected void gvEmployees_DataBound(object sender, EventArgs e)
  2.     {
  3.         if (this.gvEmployees.Rows.Count > 0)
  4.         {
  5.             gvEmployees.UseAccessibleHeader = true;
  6.             gvEmployees.HeaderRow.TableSection = TableRowSection.TableHeader;
  7.             gvEmployees.FooterRow.TableSection = TableRowSection.TableFooter;
  8.         }
  9.     }

Now download and include the jQuery and TableSorter js files as follows

  1. <script type=“text/javascript” src=“scripts/jquery-latest.js”></script>
  2. <script type=“text/javascript” src=“scripts/jquery.tablesorter.js”></script>

Initialize the table for sorting when document is ready using the below code,

  1. $(document).ready(function()
  2. {
  3.     $(“#gvEmployees”).tablesorter();
  4. });

If you are using update panel, you need to consider using pageLoad function(javascript)

  1. function pageLoad(sender, args)
  2. {
  3.     $(“#gvEmployees”).tablesorter();
  4. }

At this point the sorting should work on client side, Now you would want to set ascending and descending icons for grid headers. You could easily do this by defining these styles in your style sheet.

  1. .headerSortUp
  2. {
  3.     background-position:top;
  4.     background-repeat: no-repeat;
  5.     background-image: url(../images/icons/sort_up.gif);
  6.     background-color: #e9e7d7;
  7. }
  8. .headerSortDown
  9. {
  10.     background-position:top;
  11.     background-repeat: no-repeat;
  12.     background-image: url(../images/icons/sort_down.gif);
  13.     background-color: #e9e7d7;
  14. }

Or you could use the styles that comes with Tablesorter as follows, just set the gridView cssclassname to tablesorter

gvEmployees.CssClass = “tablesorter”;

and include the stylesheet as follows

<link rel=“stylesheet” type=“text/css” href=“themes/green/style.css” />

Tablesorter provides lots of config options, here are few important ones,

sortList: [0, 1] — This instructs to sort by index 0 column in descending order.

dateFormat: “uk” — if your format is dd/MM/yyyy, it does not seem to work by default for this format.

debug: true — this option provides you information like how much time it took and how(what type) it considered the columns.

  1. $(“#gvEmployees”).tablesorter(
  2. {
  3.     debug: true, //provides debugging information
  4.     sortList: [[0, 1]], //sorts 0th column by descending order
  5.     dateFormat: “uk”, //sets the date format to dd/MM/yyyy
  6. });

Now some interesting things, if you have columns that are formatted differently like having a thousand separator. We could use a customParser in this scenario, otherwise the data would be considered string and the sorting would not work as expected.

We should define a customParser with an id and then assign it to a column while initializing tablesorter.

  1. //define a parser
  2. $.tablesorter.addParser(
  3. {
  4.     // set a unique id
  5.     id: ‘formattedNumbers’,
  6.     is: function(s)
  7.     {
  8.         // return false so this parser is not auto detected
  9.         return false;
  10.     },
  12.     format: function(s)
  13.     {
  14.         // format your data for normalization
  15.         return s.replace(/,/g, ); //removes comma separator from formatted numbers
  16.     },
  17.     // set type, either numeric or text
  18.     type: ‘numeric’
  19. });
  21. //initialize table for sorting
  22. $(“#gvEmployees”).tablesorter(
  23. {
  24.     headers:
  25.     {
  26.         6: { sorter: ‘formattedNumbers’ }
  27.     }
  28. }) 

There might be templated columns and checkbox bound fields in the gridview and if we need to do sorting for those columns, we could do so by using textExtraction. textExtraction is similar to customParser but this applies to the whole table and gets node instead of a string for processing. Here is some code that will process templated text columns and checkbox bound columns.

  1. //define a function for extracting text from node
  2. function extractValue(node)
  3. {
  4.     var children = node.childNodes[0].childNodes.length
  6.     if (children == 0) //boundTextField or a templateColumn
  7.     {
  8.         if (node.childNodes[0].nodeType == 3)//boundTextField
  9.         {
  10.             return node.childNodes[0].data;
  11.         }
  12.         else //template column
  13.         {
  14.             var type = node.childNodes[0].type
  15.             switch (type) {
  16.                 case “checkbox”:
  17.                     return node.childNodes[0].checked.toString();
  19.                 case “radio”:
  20.                     return node.childNodes[0].checked.toString();
  22.                 case “text”:
  23.                     return node.childNodes[0].value;
  25.                 default: return “”
  26.             }
  27.         }
  28.     }
  29.     else //boundCheckboxColumn or a templateLabelColumn
  30.     {
  31.         if (node.childNodes[0].childNodes[0].nodeType == 3)
  32.         {
  33.             return node.childNodes[0].childNodes[0].data;
  34.         }
  35.         else
  36.         {
  37.             return node.childNodes[0].childNodes[0].checked.toString();
  38.         }
  39.     }
  40. }
  42. $(“#gvEmployees”).tablesorter(
  43. {
  44.     textExtraction: extractValue
  45. })

This covers most of things that one would do in gridview. The download contains all the above mentioned code.

Points of Interest

The Tablesorter is very good for the kind of functionality it provides with so much less code & effort. I am sure more and more people would be interested in this and would be using this as Microsoft recently announced it’s support to jQuery

It’s very simple to create an extended gridview control built with these functionalities.

You could download the sourcecode for sample from here Download 


What’s New in Visual Studio 2008 Service Pack 1?

It’s been a while since Microsoft released VS 2008 SP1.  You could find more details about SP1 in Scott Guthrie’s Post. ADO.NET Entity Framework is something I am looking forward to and hopefully will know more about it when I attend the session.

If you would like to know what’s new in SP1, Microsoft is conducting events across UK this month and here are the details for Manchester,

07-Oct-2008, Manchester, Regus Manchester


Event Description

Audience: Developers

“Service Pack? We’re calling it a Service Pack? Are you kidding??!?!” Visual Studio 2008 Service Pack 1 will release later in 2008 alongside .NET Framework V3.5 Service Pack 1 and, together, they represent a significant upgrade to Visual Studio 2008. There are enhancements across many areas of the .NET Framework such as data access, windows application development and web development and there are also corresponding changes in the development environment to support the new framework features.


Session 1: What’s New for Web & Windows Development?

Session 2: What’s New for Data?

For other locations in UK refer here,

If you are unable to attend, you can download the presentations from here

Presentation slides


jQuery and Visual Studio

jQuery and Visual Studio

Microsoft has announced that it’s going to make jQuery part of the Visual Studio and use it within ASP.Net AJAX framework and ASP.Net MVC framework. Not only that, Microsoft will also provide a free download for VS 2008 SP1 which would provide intellisense to jQuery within visual studio. For more info on this annoucement refer to the links below

 The best bit is that Microsoft is going to provide jQuery unchanged as it is. This means that even if Microsoft changes any of the code, it would submit a patch to jQuery like anyone else.


For the ones new to jQuery, jQuery is a lightweight open source Javascript library similar to Prototype and YUI. It allows you to easily find and manipulate HTML elements with minimum lines of code. jQuery uses an interesting concept “Chainability” to make its code short and simple. jQuery has the following features,

  1. DOM element selections
  2. DOM traversal and modification
  3. Events
  4. CSS manipulation
  5. Effects and animations
  6. Ajax
  7. Extensibility
  8. Utilities – such as browser version and the each function
  9. JavaScript Plugins – Tablesorter

jQuery Basics

Once we include the jQuery js file(downloaded from jQuery) as below, we could start using the funtions within jQuery.

<script type=“text/javascript” src=“jQuery.js”></script>
Adding an event is as simple as this,

  1. $(“a”).click(function(event){
  2.    alert(“Hello World!”);
  3.  });
 $(“a”) selects all the anchor(a) elements on the page and binds the click event to them. The same could be rewritten so that an element could be selected instead of all. This is similar to document.getElementById

  1. $(“#btnHello”).click(function(event){
  2.    alert(“Hello World!”);
  3.  });
Lets consider this example,
The above line of code makes the div visible and sets the HTML content to “Hello!”. Here we use the concept of chainability to make the code short & simple. This is easily achieved because every method within jQuery returns an object.
This example shows code to hightlight alternate rows in a table,
$(“#tblProducts tr:nth-child(even)”).addClass(“alternateRow”);
We could even do animations easily using jQuery. More on this and to sort tables using jQuery plugin – Tablesorter will be discussed in the coming days.

UG Meeting on .NET 3.5 & Design aspects of WF applications

Here are the details of this week’s BDOTNET UG meeting. It’s been a while since I attended last time, planning to attend this saturday.

UG Meeting on 15th Mar 2008 4PM

Session1: New stuff in .NET 3.5
Speaker: Chaitra, MVP – ASP.NET
Time: 4PM

Session2: Design aspects of WF-based applications
Speaker: Manoj, MVP – C#.
Time: 5PM

ENTRY: FREE and for all.

ThoughtWorks Technologies (India) Pvt Ltd.
2nd Floor, Tower C, Corporate Block, Diamond District
Airport Road, Bangalore – 560 008, India
(Opposite, TGIF Building)

Azim Premji’s lessons in life

This one is pretty old but a beautiful thought provoking speech by Azim Premji. Here it goes,

“It is always wonderful to be with young people. The funny thing about life is that you realise the value of something only when it begins to leave you. As my hair turned from black to salt and pepper, and finally salt without the pepper, I have begun to realise the importance of youth. At the same time, I have begun to truly appreciate some of the lessons I have learnt along the way. I hope you will find them useful when you plan your own career and life.

The first thing I have learnt is that we must always begin with our strengths. From the earliest years of our schooling, everyone focuses on what is wrong with us. There is an imaginary story of a rabbit. The rabbit was enrolled in a rabbit school. Like all rabbits, it could hop very well but could not swim. At the end of the year, the rabbit got high marks in hopping but failed in swimming. The parents were concerned. They said, “Forget about hopping. You are anyway good at it. Concentrate on swimming.” They sent the rabbit for tuitions in swimming. And guess what happened? The rabbit forgot how to hop! As for swimming, have you ever seen a rabbit swim? While it is important for us to know what we are not good at, we must also cherish what is good in us. That is because it is only our strengths that can give us the energy to correct our weaknesses.

The second lesson I have learnt is that a rupee earned is of far more value than five found. My friend was sharing with me the story of his eight-year-old niece. She would always complain about the breakfast. The cook tried everything possible, but the child remained unhappy. Finally, my friend took the child to a supermarket and brought one of those ready-to-cook packets. The child had to cut the packet and pour water in the dish. After that, it took two minutes in the microwave to be ready. The child found the food absolutely delicious! The difference was that she had cooked it herself!

In my own life, I have found that nothing gives as much satisfaction as earning our rewards. In fact, what is gifted or inherited follows the old rule of ‘easy come, easy go’. I guess we only know the value of what we have if we have struggled to earn it.

The third lesson I have learnt is no one bats a hundred every time. Life has many challenges. You win some, you lose some. You must enjoy winning. But do not let it go to your head. The moment it does, you are already on your way to failure. And if you do encounter failure along the way, treat it as an equally natural phenomenon. Don’t beat yourself for it or any one else for that matter! Accept it, look at your own share in the problem, learn from it and move on. The important thing is, when you lose, do not lose the lesson.

The fourth lesson I have learnt is the importance of humility. Sometimes, when you get so much in life, you really start wondering whether you deserve all of it. This brings me to the value of gratitude. We have so much to be grateful for. Our parents, our teachers and our seniors have done so much for us that we can never repay them. Many people focus on the shortcomings, because obviously no one can be perfect. But it is important to first acknowledge what we have received. Nothing in life is permanent. When a relationship ends, rather than becoming bitter, we must learn to savour the memory of the good things while they lasted.

The fifth lesson I learnt is that we must always strive for excellence. One way of achieving excellence is by looking at those better than ourselves. Keep learning what they do differently. Emulate it. But excellence cannot be imposed from the outside. We must also feel the need from within. It must become an obsession. It must involve not only our mind but also our heart and soul. Excellence is not an act but a habit. I remember the inspiring lines of a poem which says that your reach must always exceed your grasp. That is heaven on earth. Ultimately, your only competition is yourself.

The sixth lesson I have learnt is never give up in the face of adversity. It comes on you suddenly without warning. You can either succumb to self-pity and wring your hands in despair, or decide to deal with the situation with courage and dignity. Always keep in mind that it is only the test of fire that makes fine steel. A friend of mine shared this incident with me. His eight-year-old daughter was struggling away at a jigsaw puzzle. She kept at it for hours but could not succeed. Finally, it went beyond her bedtime. My friend told her, “Look, why don’t you just give up? I don’t think you will complete it tonight. Look at it another day.” The daughter looked with a strange look in her eyes, “But, dad, why should I give up? All the pieces are there! I have just got to put them together!” If we persevere long enough, we can put any problem in its perspective.

The seventh lesson I have learnt is that while you must be open to change, do not compromise on your values. Mahatma Gandhiji often said that you must open the windows of your mind, but you must not be swept off your feet by the breeze. You must define what your core values are and what you stand for. And these values are not so difficult to define. Values like honesty, integrity, consideration and humility have survived for generations.

Values are not in the words used to describe them as much as in the simple acts. At the end of the day, it is values that define a person more than the achievements. Because it is the means of achievement that decide how long the achievements will sustain. Do not be tempted by short cuts. The short cut can make you lose your way and end up becoming the longest way to your destination.

And the final lesson I learnt is that we must have faith in our own ideas even if everyone tells us that we are wrong. There was once a newspaper vendor who had a rude customer. Every morning, the customer would walk by, refuse to return the vendor’s greetings, grab the paper off the shelf and throw the money at the vendor. The vendor would pick up the money, smile politely and say, “Thank you, sir.” One day, the vendor’s assistant asked him, “Why are you always so polite to him when he is so rude to you? Why don’t you throw the newspaper at him when he comes back tomorrow?” The vendor smiled and replied, “He can’t help being rude and I can’t help being polite. Why should I let his rude behaviour dictate my politeness?

In my youth, I thought of myself as a rebel and was, many times, a rebel without a cause. Today, I realise that my rebellion was another kind of conformity. We defied our elders to fall in line with our peers!

Ultimately, we must learn to respond instead of reacting. When we respond, we evaluate with a calm mind and do whatever is most appropriate. We are in control of our actions. When we react, we are still doing what the other person wants us to do.

I wish you all the best in your life and career. I hope you achieve success in whatever way you define it and what gives you the maximum happiness in life. Remember, those who win are those who believe they can”