OnDateSelected
The OnDateSelected client-side event handler of the ASP NET AJAX Calendar is called immediately after the value of the control's selection has changed.
The event handler receives two arguments:
the object that fired the event.
an event arguments object that exposes the following methods:OnDateSelected event arguments object for RadCalendar
Name | Return Type | Arguments | Description |
---|---|---|---|
get_renderDay() | RenderDay client-side object | Returns the client-side RenderDay object for the day that was just selected or unselected. |
Name | Return Type | Arguments | Description |
---|---|---|---|
get_oldValue() | string | Returns the old value of the control, formatted as a string. | |
get_newValue() | string | Returns the new value of the control, formatted as a string | |
get_oldDate() | Date object | Returns the old value of the control as a Date object. | |
get_newDate() | Date object | Returns the new value of the control as a Date object. |
The following example shows the OnDateSelected event for RadCalendar:
<telerik:RadCalendar RenderMode="Lightweight" ID="RadCalendar1" runat="server">
<ClientEvents OnDateSelected="dateSelected" />
</telerik:RadCalendar>
function dateSelected(sender, eventArgs) {
var date = eventArgs.get_renderDay().get_date();
var dfi = sender.DateTimeFormatInfo;
var formattedDate = dfi.FormatDate(date, dfi.ShortDatePattern);
alert(formattedDate + " was just " + (eventArgs.get_renderDay().get_isSelected() ? "selected. " : "unselected. "));
}
The following example shows the OnDateSelected event for RadDatePicker. The OnDateSelected event works the same way for RadTimePicker and RadDateTimePicker.
<telerik:RadDatePicker RenderMode="Lightweight" ID="RadDatePicker1" runat="server">
<ClientEvents OnDateSelected="dateSelected" />
</telerik:RadDatePicker>
function dateSelected(sender, eventArgs) {
alert("The date was just changed from " + eventArgs.get_oldValue() + " to " + eventArgs.get_newValue());
}