Re: Date validation
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Wed, 6 Jul 2005 07:35:41 +0100
Ronnie Edgar <RonnieEdgar@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Use a custom validator for client side validation. with a datetime
> validation script as the validationscript.
>
> and server side
>
> something like
>
> try
> {
> datetime.parse (myVariable);
> }
> catch (exception ex)
> {
> throw;
> }
There's no point in catching the exception if you're just going to
throw it again - just let it bubble up if that's the behaviour you
want. If you *don't* want to throw an exception, then catch it (but
preferrably only specific ones rather than just plain Exception).
If you don't want to throw an exception, then as of .NET 2.0, you can
use DateTime.TryParse, which would be preferrable to just catching the
exception. (The exception will be a slight performance penalty - not
nearly the bugbear that it's commonly made out to be, but using
TryParse avoids it without you having to write any custom validation
code.)
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: Date validation
- From: Steve Walker
- Re: Date validation
- From: Ronnie Edgar
- Re: Date validation
- References:
- Date validation
- From: Diego
- RE: Date validation
- From: Ronnie Edgar
- Re: Date validation
- From: Diego
- Re: Date validation
- From: Ronnie Edgar
- Date validation
- Prev by Date: cannot build folder in deployment
- Next by Date: Re: Hard Question - How to make a TextBox always write in English
- Previous by thread: Re: Date validation
- Next by thread: Re: Date validation
- Index(es):
Relevant Pages
|