Thursday, May 15, 2008

Javascript Date Comparision using CustomValidator And String to Date Conversion using JavaScript

This function calculates the difference between the two Date, and Validate it,

I used this function to validate the difference between the From Date and To Date for not more then 366 days(to cover the leap year also) or less then 0,

This function is called through the CustomValidator of ASP.NET, but you can also use this without the CustomValidator.

<asp:CustomValidator runat="server" ID="custDateValidator"

ClientValidationFunction="CompareDates" Display="Dynamic"

ErrorMessage="The number of date to be included in report must be between 1 and 366">


This piece of code also depicts how we can convert the String to DateTime, because in my form I am taking the Dates from two HTML TextBoxes, which by default is String, so I had to write seperate piece of code which will convert String to DateTime.

<script language="JavaScript">

function CompareDates(source, args) {

var fromDate = new Date();

var txtFromDate = document.getElementById("txtDateFrom").value;

var aFromDate = txtFromDate.split("/");

/*Start 'Date to String' conversion block, this block is required because javascript do not provide any direct function to convert 'String to Date' */

var fdd = aFromDate[0]; //get the day part

var fmm = aFromDate[1]; //get the month part

var fyyyy = aFromDate[2]; //get the year part




var toDate = new Date();

var txtToDate = document.getElementById("txtDateTo").value;

var aToDate = txtToDate.split("/");

var tdd = aToDate[0]; //get the day part

var tmm = aToDate[1]; //get the month part

var tyyyy = aToDate[2]; //get the year part




//end of 'String to Date' conversion block

var difference = toDate.getTime() - fromDate.getTime();

var daysDifference = Math.floor(difference/1000/60/60/24);

difference -= daysDifference*1000*60*60*24;

//if diffrence is greater then 366 then invalidate, else form is valid

if(daysDifference > 366 daysDifference < 0)

args.IsValid = false;


args.IsValid = true;



I Hope this will Help.

Thursday, May 8, 2008

Microsoft .NET Framework 3.5 Namespaces Chart

Microsoft released a new poster  that provides you a nice overview of the common types and namespaces in the .NET Framework 3.5 at a single glimpse.

You can download a PDF version of the poster here


Running Multiple Version of IE in same System

If you ever been working on layout and design of website then you may need to test the layout and rendering of the website in different browser, like IE 7, IE 6, IE 5.5, FireFox, Opera, etc.

But normally it is not possible to install multiple version IE in same system. So to get through this limitation of Windows, I found the following program using this you can run multiple version of IE (IE 7.0, 6.0, 5.5, 5.1, 4.0, 3.0) in the same System,

Download it

Normally this installer will not work with Windows Vista,

Follow the progress of running Internet Explorer 6 natively on Windows Vista here!

You can get more details in Treadsoft Homepage

I hope this will help you.

Sunday, May 4, 2008

Visual Studio 2008 and .NET 3.5 Overview and Tutorials (Links)

This post will provide a quick overview of Visual Studio.NET 2008 and useful links which will give a depth understanding of of .NET 2008, Framework 3.0 and Framework 3.5.

Visual Studio 2008 was first shipped on November 2007, you can download the 90 day trial version from here

Some of the important difference and new features can be found in the link

in ASP Alliance this link will give you enough basic concepts to kick start your journey into .NET 2008, once you get through this basics, following are the useful MSDN links which will provide you with the WPF, WCF and WF (Workflow foundations) from basics to advance level programming.

Windows Communication Foundation

WPF Tutorial

WF Foundation

ASP.NET MVC Source Code

If you have windows live id (Hotmail account), and good broadband speed, you can try hands on MSDN Virtual Lab

Remember there are some or lots of features in WPF programming which requires Windows Vista OS, but don't get disappointed if you are using Windows XP SP2, you can download and install Microsoft Virtual PC at

And download free copies of Windows Vista from

This VPC image will expire on July 3, 2008.

If you have missed Virtual Tech days from Microsoft for Microsoft SQL Server 2008 and Microsoft Visual Studio 2008, you can download the Session Recordings and Presentations from the following links

If this link is not working then post you email in my the comments, I have downloaded presentations in my local system, I will try to send you.

My target of this post is for beginners who keep on hunting in Google for various links of .NET 2008, I tried to collect few good ones one single place, hope this will help and keep posted me or others if you have good links, in the comments.

Related post :

Difference Between .NET Framework 2.0 and .NET Framework 3.0

Ajax Error in Visual Studio 2008

Using LINQ with ASP.NET