This is a migrated thread and some comments may be shown as answers.

Disable a Dates in RadDatePicker Before a Selected Dates in Other RadDatePicker

2 Answers 285 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Mohammad
Top achievements
Rank 1
Mohammad asked on 20 Oct 2010, 02:48 PM

I Have 2 RadDatePicker and I’d like to ask if it’s possible to disable dates before a specific dates selected
(as airlines dates you can't select a return date before a departure date)

i used a trick that i changed the MinDate of the second RadDatePicker to the selected date of the first one in the code behind but its kind slow.


protected void pickDateFrom_OnSelectedDateChanged(object sender, EventArgs e)
        {
            if (pickDateFrom.SelectedDate.HasValue)
            {
                pickDateTo.MinDate = pickDateFrom.SelectedDate.Value;
            }
        }

is there any way to do this in JavaScript or something to make it faster

i'm Sorry this is asp.net problem not a windows forms one, admin could you please delete it or move it to the right section.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 21 Oct 2010, 11:41 AM
Hello Mohammad,

Here you can find working example for similar scenario.
Calendar / Validation

Also, we can set the MinDate and MaxDate from cleint side using the methods - set_maxDate and set_minDate:
RadDatePicker Client Object


Thanks,
Princy.
0
Mohammad
Top achievements
Rank 1
answered on 21 Oct 2010, 05:29 PM
Thank you Princy it worked :D

this is the JavaScript code if anyone interested
function SetMinDate(sender, eventArgs) {
            var pickUp = $find("<%= pickDateFrom.ClientID %>");
            var dropOff = $find("<%= pickDateTo.ClientID %>");
  
            var date = pickUp.get_selectedDate();
            if (date != null) {
                dropOff.set_minDate(date);
  
                if (dropOff.get_selectedDate() == null) {
                    dropOff.set_selectedDate(date);
                }
            }
        }


Thanks,
Mohammad.
Tags
Calendar
Asked by
Mohammad
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mohammad
Top achievements
Rank 1
Share this question
or