I keep getting this error for my DateTime Validation code at DateTime.ParseExact and have no idea what the problem is

"String was not recognized as a valid DateTime."

 String startDate = Request["txtStartDate"];
    String endDate = Request["txtEndDate"];
    DateTime start = DateTime.ParseExact(startDate, "MM/dd/yyyy",
                           System.Globalization.CultureInfo.InvariantCulture);
    DateTime end = DateTime.ParseExact(endDate, "MM/dd/yyyy",
                        System.Globalization.CultureInfo.InvariantCulture);
    if (DateTime.Compare(start, end) > 0)
    {
        txtStartDate.BackColor = System.Drawing.Color.Yellow;
        txtEndDate.BackColor = System.Drawing.Color.Yellow;
        Msg = " The end date must be a later date than the start date. ";
        lblError.Text += Msg;
        validatedState = false;

    }
    else
    {
        txtStartDate.BackColor = System.Drawing.Color.White;
        txtEndDate.BackColor = System.Drawing.Color.White;

    }

Related posts

Recent Viewed