P
Pete
Specifically, I want to force the user to enter date in a textbox as a
4 digit year so that I don't have to figure out what century they
intend. Also, I don't want to deal with date range assumptions that 2
digit year begets.
My expectation is that I can use a compareValidator, set the type to
date, then supply the format criteria as a string in ValueToCompare:
mm/dd/yyyy. After studying the newsgroups, I don't see that option
using the CompareValidator alone. I see no example of what
ValueToCompare should be if Type is Date, either. The string mnemonic
(mm/dd/yyyy, or variations) causes rendering error.
I have attempted to use the recommendation of Peter Blum:
System.Globalization.CultureInfo vCulture =
(System.Globalization.CultureInfo)
System.Globalization.CultureInfo.CreateSpecificCulture("en-US").Clone();
vCulture.DateTimeFormat.ShortDatePattern = "mm/dd/yyyy";
System.Threading.Thread.CurrentThread.CurrentUICulture = vCulture;
without success -- I can still enter a 2 digit year without getting a
validation error. I put the above in the Page_Load method of the
textbox page as prescribed. What else can I do?
It boggles the mind that one of the most common data entry problems,
dates, is so poorly documented (meaning precious few examples) and
implemented in VS 2003 -- or ASP.NET, whichever is at fault.
4 digit year so that I don't have to figure out what century they
intend. Also, I don't want to deal with date range assumptions that 2
digit year begets.
My expectation is that I can use a compareValidator, set the type to
date, then supply the format criteria as a string in ValueToCompare:
mm/dd/yyyy. After studying the newsgroups, I don't see that option
using the CompareValidator alone. I see no example of what
ValueToCompare should be if Type is Date, either. The string mnemonic
(mm/dd/yyyy, or variations) causes rendering error.
I have attempted to use the recommendation of Peter Blum:
System.Globalization.CultureInfo vCulture =
(System.Globalization.CultureInfo)
System.Globalization.CultureInfo.CreateSpecificCulture("en-US").Clone();
vCulture.DateTimeFormat.ShortDatePattern = "mm/dd/yyyy";
System.Threading.Thread.CurrentThread.CurrentUICulture = vCulture;
without success -- I can still enter a 2 digit year without getting a
validation error. I put the above in the Page_Load method of the
textbox page as prescribed. What else can I do?
It boggles the mind that one of the most common data entry problems,
dates, is so poorly documented (meaning precious few examples) and
implemented in VS 2003 -- or ASP.NET, whichever is at fault.