RadCalendar for ASP.NET AJAX

RadControls for ASP.NET AJAX

The OnPopupOpening client-side event handler is called immediately before a popup calendar or time view is initialized to the current selection in the input area and then displayed.

Note

The OnPopupOpening event is supported by: RadDatePicker, RadTimePicker, and RadDateTimePicker.

Two parameters are passed to the event handler:

  • sender is the control whose popup is opening.

  • eventArgs has the following properties:

    • get_popupControl() returns the client object for the time view or calendar that is about to be displayed.

    • set_cancelCalendarSynchronization() lets you prevent the popup control from synchronizing its value to the value in the input area.

    • set_cancel() lets you prevent the popup from appearing.

The following example uses the OnPopupOpening event to initialize the selection if the input area is empty:

CopyASPX
<script type="text/javascript">
    function InitializePopup(sender, eventArgs) {
        if (sender.isEmpty()) {
            eventArgs.set_cancelCalendarSynchronization(true);
            var popup = eventArgs.get_popupControl();
            if (popup == sender.get_calendar()) {
                if (popup.get_selectedDates().length == 0) {
                    var todaysDate = new Date();
                    var todayTriplet = [todaysDate.getFullYear(), todaysDate.getMonth() + 1, todaysDate.getDate()];
                    popup.selectDate(todayTriplet, true);
                }
            }
            else {
                var time = popup.getTime();
                if (!time) {
                    time = new Date();
                    time.setHours(12);
                    popup.setTime(time);
                }
            }
        }
    }
</script>
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server">
    <Calendar DayNameFormat="FirstLetter"
           UseColumnHeadersAsSelectors="False"
           UseRowHeadersAsSelectors="False">
    </Calendar>
    <ClientEvents OnPopupOpening="InitializePopup" />
</telerik:RadDateTimePicker>

See Also

Other Resources