Using the ASP.NET Calendar Control
When building web applications, at some point during your requirements documentation you’ll probably come across the need for users to enter dates onto a form. Working with dates may seem like a simple task but it can quite easily become very complicated.
The reason date entry becomes complex is because of the validation that needs to be performed. In older languages this validation was provided by the developer. They had to consider all kinds of conditional checks, such as the number of days in the selected month, whether the selected February was in a leap year, as well as all the rules regarding leap years.
Fortunately, ASP.NET has made this style of date programming a thing of the past. The .NET framework has a built-in calendar component which provides all the basic functionality for most development scenarios and it comes pre-programmed with all of the aforementioned validation already in place.
By using this component the developer can focus on other aspects such as presentation and usability functionality instead of worrying about whether February 2028 has 28 or 29 days.
In this tutorial we’ll look at some of the basic functionality provided by the ASP.NET Calendar component and two basic examples of common usage of this component in web applications. We’ll also look at some of the basic formatting methods provided by the Date class.
Note: This tutorial requires Visual Studio .NET and both VB.NET and C# code samples will be provided