control.get_selectedDate is not a function

2 posts, 0 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 21 Oct 2009 Link to this post

    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...


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Oct 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top