Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > use CompareValidator to validate date format

Reply
Thread Tools

use CompareValidator to validate date format

 
 
Neo
Guest
Posts: n/a
 
      06-25-2004
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


 
Reply With Quote
 
 
 
 
Peter Blum
Guest
Posts: n/a
 
      06-25-2004
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.CurrentUICul ture =
System.Globalization.CultureInfo.CreateSpecificCul ture("[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:
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

"Neo" <> wrote in message
news:ewDr%...
> 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
>
>



 
Reply With Quote
 
 
 
 
adamyang adamyang is offline
Junior Member
Join Date: Nov 2007
Posts: 1
 
      11-28-2007
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");

    }
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting date format to validate date in ruby Jay Pangmi Ruby 4 08-25-2008 03:57 PM
comparevalidator control interprets date in the wrong format VancouverMike ASP .Net 0 04-11-2008 12:26 AM
Can you validate a usercontrol property with a CompareValidator? Dave ASP .Net 1 03-25-2008 05:51 PM
CompareValidator won't validate cashdeskmac ASP .Net 3 11-26-2007 04:43 PM
Does CompareValidator work for the date in dd-mmm-yyyy format? =?Utf-8?B?Q3liZXJMb3R1cw==?= ASP .Net 3 06-10-2005 04:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57