RadCalendar for ASP.NET AJAX

RadControls for ASP.NET AJAX

The OnDateSelecting client-side event handler is called immediately before the selected dates collection is updated to reflect the selection or deselection of a date.

Note

The OnDateSelecting event is supported by: RadCalendar.

Two parameters are passed to the event handler:

  • sender is the calendar control.

  • eventArgs exposes the following properties:

    • get_renderDay() returns the client-side RenderDay object that represents the day being selected or unselected.

    • get_isSelecting() returns true if the day is about to be selected, false if it is about to be unselected.

    • set_cancel() lets you prevent the selection or deselection from occurring.

The following example uses the OnDateSelecting event to confirm a change of selection and cancel the change if the user does not confirm:

CopyASPX
<script type="text/javascript">
    function ConfirmChange(sender, eventArgs) {
        var date = eventArgs.get_renderDay().get_date();
        var dfi = sender.DateTimeFormatInfo;
        var formattedDate = dfi.FormatDate(date, dfi.ShortDatePattern);
        eventArgs.set_cancel(!confirm("Are you sure you want to " +
        (eventArgs.get_isSelecting() ? "select " : "unselect ") +
        formattedDate + "?"));
    }
</script>
<telerik:RadCalendar ID="RadCalendar1" runat="server">
    <ClientEvents OnDateSelecting="ConfirmChange" />
</telerik:RadCalendar>

See Also