Compare Validators - Date Problem
-
Hi,, I am using Compare validators to compare two dates. One of them is as below. Now I need to enter dates in dd/MM/yyyy format. But the Compare validator takes the default date format as MM/dd/yyyy. So if I have two dates as 5/7/2005 2/8/2005 the above date proves to be greater than the below date, as it compares mm/dd/yyyy format, and my validation gets wrong. Can anyone tell me how to change the Datechecking format of the validator? Or any other options... Thanks
-
Hi,, I am using Compare validators to compare two dates. One of them is as below. Now I need to enter dates in dd/MM/yyyy format. But the Compare validator takes the default date format as MM/dd/yyyy. So if I have two dates as 5/7/2005 2/8/2005 the above date proves to be greater than the below date, as it compares mm/dd/yyyy format, and my validation gets wrong. Can anyone tell me how to change the Datechecking format of the validator? Or any other options... Thanks
-
Create a CultureInfo for your locale and put it in Thread.CurrentCulture to alter the date format. Example for settings swedish culture:
Thread.CurrentCulture = new CultureInfo(1053);
--- b { font-weight: normal; }Sorry didnt get u. Where should I code for Thread.CurrentCulture? Thanks
-
Sorry didnt get u. Where should I code for Thread.CurrentCulture? Thanks
-
Make sure that it happens before the validation. In global.asax might be a good place. --- b { font-weight: normal; }
Thanks a lot. It worked out... I found another option too To put culture="en-GB" uiCulture="en-GB" in Web.config, Globalization section. Thanks
-
Thanks a lot. It worked out... I found another option too To put culture="en-GB" uiCulture="en-GB" in Web.config, Globalization section. Thanks
-
Hi there, In addition to placing the settings in the web.config file and it will affect the entire application, you can also set those properties in the
Page
directive for a specific web page.How to do that? Also let me know ... If I have specified a setting in web.config for culture, Is it possible to specify another date format in a particular control. I tried doing this but it throws an error. Like I have specified "dd/MM/yyyy" in web.config. I want a particular dateformat in a variable to be in MM/dd/yyyy format, so i just used .ToString("MM/dd/yyyy",new CultureInfo("en-GB")) but it gave an error... Just wanted to know this... Thanks...
-
How to do that? Also let me know ... If I have specified a setting in web.config for culture, Is it possible to specify another date format in a particular control. I tried doing this but it throws an error. Like I have specified "dd/MM/yyyy" in web.config. I want a particular dateformat in a variable to be in MM/dd/yyyy format, so i just used .ToString("MM/dd/yyyy",new CultureInfo("en-GB")) but it gave an error... Just wanted to know this... Thanks...
It looks something like:
<%@ Page UICulture="en" Culture="en-GB"...%>
At runtime, you can format the value of the DateTime type for a specific culture, you can take a look at here[^] for more information. Since you didn't say what is the error, what your failure code looks like, so I have no idea why.