A newer version of this page is available. Switch to the current version.

ASPxClientCalendar.SetSelectedDate(date) Method

Sets the calendar's selected date.

Declaration

SetSelectedDate(date: Date): void

Parameters

Name Type Description
date Date

A date object that specifies the calendar's selected date.

Remarks

Use the SetSelectedDate method to specify the calendar's selected date that is a date-time representation of the of the calendar's value. The value edited by the calendar can also be accessed or changed via the ASPxClientEditBase.GetValue or ASPxClientEditBase.SetValue methods, respectively.

Examples

This example illustrates how make the specified date visible, and then select it using the SetSelectedDate method.

See also:How to make the specified month and year visible

function btn_OnClick(s, e) {
    if (!ASPxClientEdit.ValidateEditorsInContainer(null))
        return;
    var year = cmbYear.GetValue();
    var month = cmbMonth.GetValue();
    var day = spDay.GetValue(); ;
    var myDate = new Date(year, month, day);

    calendar.SetVisibleDate(myDate); // make the date visible
    calendar.SetSelectedDate(myDate); // select the date
}

function cmbMonth_OnSelectedIndexChanged(s, e) {
    var month = parseInt(cmbMonth.GetValue());
    var maxDay;
    switch (month) {
        case 1:
            maxDay = 28;
            break;
        case 3:
            maxDay = 30;
            break;
        case 5:
            maxDay = 30;
            break;
        case 8:
            maxDay = 30;
            break;
        case 10:
            maxDay = 30;
            break;
        default:
            maxDay = 31;
    }

    spDay.SetMinValue(1);
    spDay.SetMaxValue(maxDay);
}
See Also