use CompareValidator to validate date format

N

Neo

I use CompareValidator to validate a date. But CompareValidator can only one
date format at one time. if the dateorder is "mdy", date format can only be
mdy even if date format is ymd. But users of a web application may be
around the world and since database can accept many date format, so are
there any ways to let CompareValidator accept many data formats at one
time?

Thanks
 
P

Peter Blum

The page sent to the browser only needs to handle the one date format of the
user. Your task is to identify the format of the user who is requesting the
page. Once done, you set
System.Threading.Thread.CurrentThread.CurrentUICulture =
System.Globalization.CultureInfo.CreateSpecificCulture("[the Culture Name]")

Please see the .net documentation for the CultureInfo class to understand
about Culture Names.

Here are some ways to identify the user's culture:
1. Have the user pick their culture as they enter the site and keep that
information in the Session
2. If the user logs in, keep their culture with their login data
3. The browser passes a list of culture names in Request.UserLanguages. See
the .net docs for that property. Be aware that often UserLanguages is an
empty collection and you need to provide a default.

There is one more way to do this: Show the format you want right on the
page.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
and "Peter's Date Package" at
http://www.peterblum.com/datecontrols/home.aspx
 
Joined
Nov 28, 2007
Messages
1
Reaction score
0
In the Session_Start method of your global.asax

put
Code:
        System.Threading.Thread.CurrentThread.CurrentUICulture =
            System.Globalization.CultureInfo.CreateSpecificCulture("your culture code");
example
Code:
   void Session_Start(object sender, EventArgs e) 
    {
        System.Threading.Thread.CurrentThread.CurrentUICulture =
            System.Globalization.CultureInfo.CreateSpecificCulture("en-NZ");

    }
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top