|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
UpdatesThanks 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. IntroductionOne 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 BackgroundI remember that in the old days of ASP, there was a lengthy JavaScript solution we used to use, that would be perfect for what I was trying to do now. I asked a few people, and a lot of guys sent me the same code back. Full credit must go to Tan Ling Wee for writing the original JavaScript code, even though I've never met him (or her - not quite sure), and to all the people who passed it on until it eventually arrived in my email box. Now here was a piece of code perfect for what I needed to do, but it's over 600 lines long, and there's no way in hell I was going to manually reformat it line by line so that I could render it to the client. So, as any really lazy developer does things, I wrote my own app to process the JavaScript and return a code block that I could simply copy and paste into Visual Studio (will write another article on this, and upload the app for use by all). After that, it was simply a matter of writing a new class that inherited from the control, added properties to make the control customizable, and compiled. Using the codeIf 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"
Namespace="DatePicker.iX.Controls"
Assembly="DatePicker" %>
Then place the control on the page like so: <cc1:DatePicker id="DatePicker1" runat="server"
imgDirectory="/WebApplication6/img/" DateType="dd mmm yyyy">
</cc1:DatePicker>
You'll notice the properties
|
||||||||||||||||||||||