I am searching data based on two dates a from field and a To field in Asp.net
I want to prevent the user from entering a From date greater than a To date and display a message to the user Please select a valid date range
DateTime InvoiceDateFrom = new DateTime();
DateTime InvoiceDateTo = new DateTime();
if (TxtInvoiceDateFrom.Text.Trim() != "")
{
//DateTime FromDate = DateTime.ParseExact(TxtInvoiceDateFrom.Text.Trim(), "dd/MM/yyyy", null).AddDays(1);
InvoiceDateFrom = Convert.ToDateTime(TxtInvoiceDateFrom.Text);
//DateTime toDate = DateTime.ParseExact(TxtInvoiceDateTo.Text.Trim(), "dd/MM/yyyy", null).AddDays(1);
}
if (TxtInvoiceDateTo.Text.Trim() != "")
{
InvoiceDateTo = Convert.ToDateTime(TxtInvoiceDateTo.Text);
}
1 Answer