How about the "official" approach... The CompareValidator determines if
dates, integers, currencies and decimals are in a valid format and it
follows the CultureInfo object associated with the page to determine format.
Set the CompareValidator.Type=Date and Operator=DataTypeCheck.
A web form uses the culture associated with the current thread
(System.Threading.Thread.CurrentThread.CurrentCult ure). So create the
CultureInfo object with its DateTimeFormat property using
ShortDatePattern="MM-dd-yyyy" and DateSeparator="-". You can do this either
at the beginning of Page_Load or in the Global.asax file in the
Application_BeginThread method (if this is a global setting).
FYI: If you are looking for a DateTextBox with popup calendar and supporting
validators that can support this date format, check out my "Peter's Date
Package" at
http://www.peterblum.com/datecontrols/home.aspx.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Chris" <ch********@pandora.be> wrote in message
news:0t*********************@phobos.telenet-ops.be...
Hi,
I have a texbox in a webform that is supposed to hold Dates in a specific
format :
e.g. 20-12-2004
What is the best way to make sure that the entered data is in the correct
format ?
Is there a possibillity to use a special kind of control for that purpose,
as in Winforms where one can use the DateTimePicker.
thnx
Chris