CompareValidator, Dates, switching Thread culture, need help urgently

G

gauthier

Hi,

I'm developing a web application available in multiple languages.

When we switch language (via a drop down list), we switch the culture of the
current thread:

System.Threading.Thread.CurrentThread.CurrentUICulture = SelectedCulture;

the problem is that I use a CompareValidator on dates:

codebehind:
dateCompareValidator.ValueToCompare = DateTime.Today.ToShortDateString();


frontcode:
<asp:CompareValidator id="dateCompareValidator" runat="server"
ControlToValidate="dbFooterStatusEndDate" Type="Date"
Operator="GreaterThanEqual" display="none"/>

if the current thread culture is not the same than the application server
culture, then I got exception (I've switched to english culture but my
server is a french server)



Page : http://localhost/Nemo.WebApplication/supplier/search/default.aspx
Méthode : System.Web
Message d'erreur : La valeur '6/29/2005' de la propriété ValueToCompare de
'dateCompareValidator' ne peut pas être convertie en type 'Date'.
Nom de l'exception : HttpException
Stack Trace : at
System.Web.UI.WebControls.CompareValidator.ControlPropertiesValid()
at System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
at System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
.....


What is the solution to this problem?

Thanks alot.

Nicolas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top