dtrick
asked on
International Date ToolTip
I have a page that accepts a date in a TextBox. I have a CompareValidator pointed to this TextBox that ensures the value inside the TextBox is a date.
So now I would like to inform the user what format they should enter their date as. So for a site that is operating in the US I should be able to tell them that the format is something like "mm/dd/yyyy". OR if they are in Australia the format should be "dd/mm/yyyy". Or in Germany "dd.mm.yyyy" (or something like that).
The key for this is that I don't want to hard-code the value. I also don't want to use a conditional statement like:
IF (US) THEN "mm/dd/yyyy" ELSE "dd/mm/yyyy"
I am wondering if there is some property on the "CurrentCulture" or "CurrentUICulture" objects that would facilitate the automatic generation of a valid short date.
So now I would like to inform the user what format they should enter their date as. So for a site that is operating in the US I should be able to tell them that the format is something like "mm/dd/yyyy". OR if they are in Australia the format should be "dd/mm/yyyy". Or in Germany "dd.mm.yyyy" (or something like that).
The key for this is that I don't want to hard-code the value. I also don't want to use a conditional statement like:
IF (US) THEN "mm/dd/yyyy" ELSE "dd/mm/yyyy"
I am wondering if there is some property on the "CurrentCulture" or "CurrentUICulture" objects that would facilitate the automatic generation of a valid short date.
ASKER
That gets me close to what I'm looking for. That provided me with the string "M/d/yyyy". Technically speaking that is 'proper' format. Unfortunately for me I'm looking for the more user recognizable format of "mm/dd/yyyy". Any thoughts on achieving this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think you are right in that I'll probably need to fudge it. I'm thinking the best way for me to proceed is to manipulate the value that comes out of the 'ShortDatePattern'. I'll probably run a RegEx on the string to find any non-repeating 'M' and replace it with 'MM'. Then do the same for 'D'. Lastly, I'd run a toLower() on the string. Its more computation than I like, but that is the price you pay for being dynamic.
string format = System.Threading.Thread.Cu
Bob