set min date to 1/1/1900
set max date to 12/31/2099
user opens webform on existing record with date of 1/15/2300 (outside min/max date)
a runtime error occurs.
Question(s):
Why the runtime error? this is causing us grief. why doesn't validation just trigger on the datepicker control and display a validation error in the ui?
If i add the datepicker to 100s of forms, do i really have to add try/catch error handling for each when setting the date value of the control? this is a real pain.
8 Answers, 1 is accepted

One suggestion is to check the date before setting it as the selected value.
C#:
if
((date>RadDatePicker1.MinDate) && (date<RadDatePicker1.MaxDate))
RadDatePicker1.SelectedDate = date;
Thanks,
Shinu.

The observed behavior is actually no issue with the date-picker control but a piece of design logic that has its purpose and intention. Suppose, for example, that a developer has attached a click event handler to a button control. In the click event handler he is setting the new date to the date-picker control and upon that uses the new entry to execute some other business requirement such as updating a database with the new date or loading data into a grid control that is filtered by the new date. If we were to throw no exception upon a new invalid date being set all the subsequent business logic will fail and the application will behave abnormally.
Besides, that's probably exactly what some of our clients have implemented in their project and as a result they are counting on the date-picker control to throw the exception in question - so we are also running the risk of introducing breaking changes into their applications if we were to change the picker SelectedDate setter along the lines of your requirement.
Thanks for the undestanding.
Tsvetoslav
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Could you give me more details on what is supposed to happen after the exception is ignored - should the new invalid date be displayed in the date-picker despite all and if so, should it have the invalid date style (yellow color with a exclamation mark triangle) or should the date-picker be left blank. I need this information so that our development team can make an informed decision on the possible implementation of your requirement.
Regards,Tsvetoslav
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

I am glad to inform you that the feature required by you has been implemeted into the RadDatePicker and RadDateInput controls. Now they sport a SkipMinMaxDateValidationOnServer property that if switched on should produce the behavior you desire.
The new improvement will be available in the next latest internal build that should come out by the end of the day tomorrow.
Tsvetoslav
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
