Edit this page

OnDateSelecting

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.

The event handler receives two arguments:

  1. the RadCalendar object that fired the event.

  2. an event arguments object that exposes the following methods:OnDateSelecting event arguments object

Name Return Type Arguments Description
get_renderDay() RenderDay client-side object Returns the client-side RenderDay object that represents the day being selected or unselected.
get_isSelecting() bool Returns true if the day is about to be selected, false if it is about to be unselected.
set_cancel(value) bool 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:

<telerik:RadCalendar RenderMode="Lightweight" ID="RadCalendar1" runat="server">
    <ClientEvents OnDateSelecting="confirmChange" />
</telerik:RadCalendar>
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 + "?"));
}

See Also