Friday, August 6, 2010

Calendar control in C#.Net 2.0?

Calendar control in C#.Net 2.0


03 Jul, 2007








Author: Jegan Kumar

















Can you tell me, how to select more than one date (non continuous) in calendar control C#.net 2.0





ex:


to select: 2 may 2007 and 15 may 2007





Next:





How to compare a date with all dates in a month in calendar control. Why b'cos i have to change the background color of the date which is equal to comparing date.?Calendar control in C#.Net 2.0?
To use a calender control in ur application, place a calender control on ur page.


Then u can access its properties like:


1. To pick the selected date, type:


Calendar1.SelectedDate.ToLongDateStrin鈥?br>

2. To add some days to the date, you can use addmonths() or adddays() functions..


IN this way, you can access the various properties of calender control..





To compare a date with all dates in a month in calendar control:





DateTime dt1 = new DateTime(you can allow the user to enter the date);


DateTime dt2 = new DateTime(date with which you want to compare);


if (DateTime.Compare(dt1, dt2) %26lt; 0)


{


Console.WriteLine(';second date is larger than the first date';);


}


else if (DateTime.Compare(dt1, dt2) == 0)


{


Console.WriteLine(';second date is same as first date';);


}


else


{


Console.WriteLine(';second date is smaller than the first date';);


}





Let me know if that works well and if u wanna solve some particular problem.

No comments:

Post a Comment