🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #114

Re: [ASP.NET] Sprawdzenie poprawno¶ci TextBox typu DateTime

#114
From: itpartner
Date: Fri, 24 Oct 2003 07:18
68 lines
2831 bytes
mo�esz zawsze u�y� CustomValidator  a w nim funcji do strawdzania
poprawno�ci daty i czasu takiej jak ta np.

string[] ExpectedDateTimeFormats = new string[] {"yyyy-dd-MM HH:mm:ss" };

public static DateTime ParseDateTime(string date){

  System.Globalization.CultureInfo format =

    new System.Globalization.CultureInfo("pl-PL", true);

    if(date == null){

        throw new ArgumentNullException("Argument can't be null");

    }

    else if(date == "") {

        throw new FormatException("Argument can't be empty");

}

else{


return System.DateTime.ParseExact( date, ExpectedDateTimeFormats,format,
System.Globalization.DateTimeStyles.AllowWhiteSpaces);


}

}

Pozdrawiam
Mariusz Fiszer
www.atarel.com


U�ytkownik "S�awomir Partyka" <slawomir.par...@ecg.com.pl> napisa�
w wiadomo�ci news:bluuc0$1r3h$1@news.mm.pl...
> Witam,
>
> Jest TextBox w kt�rym u�ytkownik ma wprowadzi� czas w formacie "rrrr-dd-mm
> gg:mm:ss".
> Jak sprawdzi� czy u�ytkownik wprowadzi� prawid�owy czas?
> Pr�bowa�em r�nie:
> 1. CompareValidator; Operator=DataTypeCheck, Type=Date
> Niestety, sprawdza tylko format Date, nie sprawdza DateTime. Mo�na
> oczywi�cie rozbi� pola na Date i Time ale wtedy pozostaje i tak do
> sprawdzenia Time.
> 2. RangeValidator.
> Jak wpisa� dla formatu DateTime pola MinimumValue oraz MaximumValue i czy
to
> w og�le zadzia�a z DateTime?
> 3. CustomValidator.
> Tu niestety trzeba zna� JScript a ja dopiero ucz� si� C#.
>
> W ko�cu zrobi�em sprawdzanie we w�asnej metodzie ale mi�o by�oby
skorzysta�
> z ValidationSummary.
>
> Czy kto� ma mo�e jaki� pomys�, kt�rym m�g�by si� podzieli�?
>
> Pozdrawiam :-)
> SP
>
>
Technical Details
Message-ID: <bnajr1$6f$1@nemesis.news.tpi.pl>
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
References: <bluuc0$1r3h$1@news.mm.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
From: "itpartner" <itpa...@poczta.onet.pl>
Newsgroups: alt.pl.comp.lang.csharp,ms-news.pl.programowanie.dotnet
Subject: Re: [ASP.NET] Sprawdzenie poprawno¶ci TextBox typu
 DateTime
Date: Fri, 24 Oct 2003 09:18:47 +0200
Organization: tp.internet - http://www.tpi.pl/
Lines: 70
Message-ID: <bnajr1$6f$1@nemesis.news.tpi.pl>
References: <bluuc0$1r3h$1@news.mm.pl>
Reply-To: "itpartner" <itpa...@poczta.onet.pl>
NNTP-Posting-Host: pb186.wroclaw.sdi.tpnet.pl
X-Trace: nemesis.news.tpi.pl 1066980002 207 213.25.232.186 (24 Oct 2003 07:20:02 GMT)
X-Complaints-To: use...@tpi.pl
NNTP-Posting-Date: Fri, 24 Oct 2003 07:20:02 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit