Thursday, 15 May 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">

</asp:CustomValidator>

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

fromDate.setUTCDate(fdd);

fromDate.setUTCMonth(fmm-1);

fromDate.setUTCFullYear(fyyyy);

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

toDate.setUTCDate(tdd);

toDate.setUTCMonth(tmm-1);

toDate.setUTCFullYear(tyyyy);

//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;

else

args.IsValid = true;

}

</script>

I Hope this will Help.

Share:

Thursday, 8 May 2008

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.

Share:

Sunday, 4 May 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

http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx.

And download free copies of Windows Vista from http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&displaylang=en

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

http://www.microsoft.com/india/virtualtechdays/

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

Share:

Thursday, 24 April 2008

Ajax Error in Visual Studio 2008


Sometimes if we try to deploy an existing .NET ASP.NET 2.0 application which includes Ajax 1.0 library using Visual Studio 2005 we get following error


Could not load file or assembly ‘System.Web.Extensions, Version=3.5.0.0, ….


If you are using Ajax Famework Library, Visual Studio 2005 and Visual Studio 2008 installed in the same machine there are somethings you should be aware of.


Microsoft suggests that after the VS 2008 Beta 2 installation has finished, you should run this script to ensure that the installation of .NET Framework 3.5 Beta 2 will not affect the development of ASP.NET AJAX 1.0 applications.


If you want to target the AJAX 1.0 in Visual Studio 2008, check out this post Targeting AJAX 1.0 in VS 2008


Share:

Saturday, 19 April 2008

Six Quick Crystal Reports Design Tips

Creating reports can be a daunting task. Reports can demand a great deal of effort and time, especially if you have not worked with Crystal Reports much. In this article, Jeff provides six quick Crystal Reports Design Tips to assist in creating killer reports with style and speed. Among other tips, you will learn how to add WaterMarks to your reports. Each tip has been deeply examined with the help of relevant explanations and screenshots for better understanding.


Article Contents:


by Jeff McWherter


Read More....
Share:

Disable right mouse click, Disable Browser Back Button

Sometime our application demands to change some of the normal workflow of the Browsers. Here are the few tweaks in programming which may help you to do that.

Do not allow user to view page using browser back button.

<%Response.Cache.SetCacheability(HttpCacheability.NoCache); %>

Disable Right Click

This is a cross browser DHTML script that will prevent the default right menu from popping up when the right mouse is clicked on the web page. Use it to stop surfers from easily saving your web page, viewing its source, or lifting images off your site when using either IE 4+ or NS 4+.

<script language=JavaScript>
<!--

var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layersdocument.getElementById&&!document.all){
if (e.which==2e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>

Share: