I've seen a lot of complicated ways of finding out whether a date is valid or not. I have a textbox which has no user input validation and I am trying to convert the valid entered in it into a date, in order to test whether or not the date is valid.
It seems to work so far, but I wondered if it is advisable to do it this way? My code is below:
try
{
DateTime DateFrom = Convert.ToDateTime(txtDateFrom.Text);
}
catch
{
lblLogResult.Text += "Invalid Date From";
}
Thanks,
Mike
It seems to work so far, but I wondered if it is advisable to do it this way? My code is below:
try
{
DateTime DateFrom = Convert.ToDateTime(txtDateFrom.Text);
}
catch
{
lblLogResult.Text += "Invalid Date From";
}
Thanks,
Mike