This is a migrated thread and some comments may be shown as answers.

control.get_selectedDate is not a function

1 Answer 309 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Datamex
Top achievements
Rank 2
Datamex asked on 21 Oct 2009, 09:40 AM
Dear Telerik,

I'm trying to let one RadDateTimePicker communicate with another RadDateTimePicker; when I change the date and or time in the first control, I want to calculate the difference between the old and the new value and pass the difference to the other RadDateTimePicker, so I did the following:

In my AppFormView I created two RadDateTimePickers:

<telerik:RadDateTimePicker ID="rdtpAppointments_StartTime" SelectedDate='<%# Bind("StartedOn") %>' runat="server">  
  <DateInput> 
    <ClientEvents OnValueChanged="OnDateSelected" /> 
  </DateInput> 
</telerik:RadDateTimePicker> 

And
<telerik:RadDateTimePicker ID="rdtpAppointments_EndTime" runat="server" SelectedDate="<%# Bind('EndedOn') %>" /> 

I wrote the following Javascript code:

function OnDateSelected(sender, eventArgs) {  
    var endTimePicker = document.getElementById('<%= AppFormView.FindControl("rdtpAppointments_EndTime").ClientID%>'); ;  
 
    var newValue = new Date(eventArgs.get_newDate());  
    var oldValue = new Date(eventArgs.get_oldDate());  
    var difference = Math.round((newValue - oldValue) / 86400000);  
 
    var oldDate = new Date(endTimePicker.get_selectedDate())  
    var newDate = oldDate.setDate(oldDate.getDate()+difference);  
 
    endTimePicker.set_selectedDate() = newDate;      
  } 

In short it retrieves the old and new date for the first combobox, it calculates the difference in days and then I want to retrieve the current date selected in the RadDateTimePicker and add the same difference to it.

Only, I get the following error: endTimePicker.get_selectedDate is not a function, on the "var oldDate"-line.

What am I doing wrong?! When I look here, get_selectedDate is simply documented...


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Oct 2009, 09:52 AM
Hello,

Try the $find() method (since you are using RadControls for ASP.NET AJAX version) in order to get the clientside object of RadDatePicker instead of document.getElementByID.
Checkout the documentation which shows how to access client side object: Client-Side Basics

-Shinu.
Tags
Calendar
Asked by
Datamex
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or