Populate DatePicker with JavaScript issue

3 posts, 0 answers
  1. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 03 May 2010 Link to this post

    Here is my code...
      strDOB = strDOB & "/" & mid(USBHID.GetTrack(2), 30, 2) & "/" & mid(USBHID.GetTrack(2), 32, 2)  
    document.getElementById ("ctl00_ContentPlaceHolder1_fvClients_DOBTextBox").value = strDOB 
    It should populate my datepicker with the date of birth from my Javascript.

    However this dosen't work using the control above, nothing is entered into the datepicker (and yes I have verified the variable holding the date is valid using an alert box) and looking at my rendered source code, I see that RadCalendar produces two more input controls:
    ctl00_ContentPlaceHolder1_fvClients_DOBTextBox_dateInput_text
    ctl00_ContentPlaceHolder1_fvClients_DOBTextBox_dateInput

    If I change my JS code to populate these input boxes, I start to see results, however they still do not work.  If I use the input control which ends in "dateInput" and then click in the radDatePicker after it populates, the input control clears and the date is lost.

    Then if I use the input control which ends in "dateInput_text" and then click in the radDatePicker after it populates, the input control changes to "0NaN/0NaN/0NaN" and the date reverts back default "minDate" of 1998/12/31

    So my question is, using JS what input control should I be targeting and how do I get the date to "stick" even when someone clicks in the datePicker control field?
  2. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 06 May 2010 Link to this post

    Anyone?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 07 May 2010 Link to this post

    Hello Brett,

    You should use the datepicker's API to set a value, not DOM operations. Here is the API:

    http://www.telerik.com/help/aspnet-ajax/calendar_clientsideraddatepicker.html

    set_selectedDate() is what you need. The method should be executed to the control's instance, not a DOM element.

    http://www.telerik.com/help/aspnet-ajax/calendar_clientsidebasics.html

    Greetings,
    Dimo
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top