0

我使用文本框并从日历中获取选定的日期。之后我使用这样的范围验证器

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!"

在运行时,我收到这样的错误

System.Web.HttpException: The value '26-Jul-12' of the MaximumValue property of 'rvDate' cannot be converted to type 'Date'. 我怎么解决这个问题?

4

1 回答 1

0

验证器将在最大值上调用 DateTime.Parse,因为您将类型提供为日期,但它失败了。什么是 Date.Today?

也检查这个链接:ASP.NET RangeValidator 怪异与最大值

于 2012-07-19T03:44:47.413 回答