Avatar of jeremyduj
jeremyduj
 asked on

datetime validation

How do you validate a date in C#?

Is there something along the lines of:
txtDateBox is a textbox that user enters a date into...

if( Convert.ToDateTime(txtDateBox.Text).IsValidDate == true )   //would return bool true or false...
{
then date is valid
}
else
{
then date is NOT valid
}

I absolutely don't want to use validator controls! They wreak havok on my pages - I'd rather not use them. And they freeze the entire page if you don't enter in a correct date! I need a backend way to validate whether it is a valid date or not. There has to be a way - can anybody help?
Thanks in advance.
ASP.NETC#

Avatar of undefined
Last Comment
rodmjay

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
rodmjay

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck