Thanks to Camilo Orozco for providing me with the translated uncompiled C# code. The .cs file had been added to the source code zip. Sorry it's taken so long to post.
One of the most common causes of application failure, especially for new developers, is handling date input from the user. If it's in the wrong format and you try to write it to the database, then the database command fails. If the user switches the day and month then your date could be wrong, even if you're using a regular expression validator (i.e. 01/02/2004 could be 2 January 2004 or 1 February 2004).
To get around this, I used to wire a server side calendar control to the textbox
onClick event, and launch it in a new window, forcing the user to select a date, then return the date in the format of my choice to the textbox. But while this is all well and good for simple web apps, this week I needed the same functionality to be launched from inside a server component I was writing.
Using the code
If you're using Visual Studio, you can simply add the control to the Toolbox, and then drag and drop it into your apps. For everyone else, first copy the DLL to the bin directory of your project. Then, on your aspx page, you'll first need to register the component as follows:
<%@ Register TagPrefix="cc1"
Then place the control on the page like so:
<cc1:DatePicker id="DatePicker1" runat="server"
imgDirectory="/WebApplication6/img/" DateType="dd mmm yyyy">
You'll notice the properties
imgDirectory is the path to the directory where the control images needed can be found (images included in the download files).
DateType is the format in which the date should be returned. "dd mmm yyyy" writes out the full date, e.g. "01 January 2003", but this can be changed to any format by changing this property (e.g. "dd/mm/yyyy" or "mm/dd/yyyy"). There is also a
CssClass property, which sets the
CssClass for the textbox, and a
Text property, to set the start text to be displayed in the textbox.
Doug is an Applications Integrator for an online gaming company. He has been programming for 9 years, and has been working with the .NET framework since the beginning of 2003, in both VB.NET & C#.