0

I use a textbox and get the selected date from calendar. After that I use a range validator like this

Calendar1.SelectionMode = CalendarSelectionMode.Day
Calendar1.SelectedDate = Date.Today
rvDate.ControlToValidate = "txtValidate"
rvDate.Type = ValidationDataType.Date
rvDate.MinimumValue = DateTime.Now.ToShortDateString()
rvDate.MaximumValue = ((Date.Today).AddDays(7)).ToShortDateString()
rvDate.ErrorMessage = "Select date between today to next 7 day!"

During run time, I got error like this

System.Web.HttpException: The value '26-Jul-12' of the MaximumValue property of 'rvDate' cannot be converted to type 'Date'. How can I solve this problem?

Rob
  • 4,927
  • 12
  • 49
  • 54

1 Answers1

0

The validator will call DateTime.Parse on the MaximumValue, as you provided the Type as Date, and it is failing. What is Date.Today?

Check this link too : ASP.NET RangeValidator weirdness with MaximumValue

Community
  • 1
  • 1
Anuraj
  • 18,859
  • 7
  • 53
  • 79