UnSelect Date in Rad Date Time Picker

9 posts, 0 answers
  1. siva
    siva avatar
    4 posts
    Member since:
    Nov 2007

    Posted 24 Sep 2009 Link to this post

    Hi,
    I am selecting a date in RadDateTime Picker and I am validating selected date in OnDateSelected()  client event based on some validation i m clearing the textbox in RadDateTime Picker 1. But the problem is selected date is not clearing in RadDateTime Picker .

    function

     

    ValidateWithDtEntryDate(sender,e)

     

    {

     

    var datePicker2 = $find("<%= datepicker2.ClientID %>");
    here i am doing validtion with datepicker2  and clearing textbox in  datepicker1 but the prblm is how to clear sellected date in datetimepicker1.
    }

     

     

    <telerik:RadDatePicker ID="datetimepicker1" runat ="server" >

     

     

     

     

     

    <DateInput ID="DateInputSentQcDate" DateFormat="MM/dd/yyyy" style="color:Navy" ReadOnly ="true" runat ="server"></DateInput>

     

     

     

     

     

    <ClientEvents OnDateSelected="ValidateWithDtEntryDate"  />

     

     

     

     

     

    </telerik:RadDatePicker>

     

  2. Ty
    Ty avatar
    2 posts
    Member since:
    Jan 2009

    Posted 24 Sep 2009 Link to this post

    To clear the datetimepicker set the SelectedDate property to null.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Sep 2009 Link to this post

    Hi Siva,

    You could use the clear() method in order to clear the SelectedDate. See the example shown below.

    JavaScript:
     
    <script type="text/javascript"
    function ValidateWithDtEntryDate(sender,e) 
        var datePicker2 = $find("<%= datepicker1.ClientID %>"); 
        // Do Validation 
        if(validationResult) // Chck with Condition 
        { 
             datePicker2.clear();  // Clear the SelectedDate of RadDatePicker1 
        } 
     
     
     
    </script> 

    -Shinu.
  5. siva
    siva avatar
    4 posts
    Member since:
    Nov 2007

    Posted 29 Sep 2009 Link to this post

    HI,
    Thanks for your response.
    I used clear() to clear the date but i am getting error like   'null' is null or not an object.I am using this functionality in user control.
    So instead of clear() in calendar i am clearing textbox value in raddatepicker.But the problem is my validation(firstdate==second date) is working in first case  as per validation and i am able to show alert. If i press  ok of that showed alert and again i select same date my validation function ValidateWithDtEntryDate() is not firing to show validation alert instead it displaying selected date in textbox of datetimepicker.

    Please give me a solution for this.

    Thanks,
    Siva
  6. Pree
    Pree avatar
    3 posts
    Member since:
    Nov 2012

    Posted 23 Nov 2012 Link to this post

    hi
    i have a raddatetimepicker and if the user enters the date it works OK, but if he later tries not to enter the date and presses backspace ,the page directs to the previous page,he is not able to deselect the date..
    Please help
  7. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 28 Nov 2012 Link to this post

    Hi Pree,

    I am afraid we are not able to replicate the issue locally. Could you reproduce this behavior with any of our demos?
    http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/custompopup/defaultcs.aspx

    Please provide us the exact steps to reproduce the issue or open a support ticket to send us a sample runnable application demonstrating the erratic behavior. Thus, we will be able to further analyze the problem and provide a proper solution.

    Regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Pree
    Pree avatar
    3 posts
    Member since:
    Nov 2012

    Posted 28 Nov 2012 Link to this post

    Hi
    I"ll tell you the steps:

    <div class="sxlb">
                                   <asp:Label ID="lblLastBackgroundCheckedDate" runat="server" AssociatedControlID="dpLastBackgroundCheckedDate"
                                       Text="Last Background Checked Date"></asp:Label></div>
                               <div class="sxlm">
                                   <lpsfs:SysXDatePicker runat="server" ID="dpLastBackgroundCheckedDate" DateInput-ReadOnly="true"
                                       DateInput-DateFormat="MM-dd-yyyy" Width="99%">
                                       <ClientEvents OnPopupClosing="FocusOnPopUpButton" />
                                       <Calendar ID="calLastBackgroundCheckedDat" runat="server" EnableKeyboardNavigation="true"
                                           CausesValidation="false">
                                       </Calendar>
                                   </lpsfs:SysXDatePicker>
                                   <div class="vldx">
                                       <asp:CompareValidator ID="cmpLastBackgroundCheckedDate" ControlToValidate="dpLastBackgroundCheckedDate"
                                           class="errmsg" ValidationGroup="grpSupplierInformation" Operator="LessThanEqual"
                                           Display="Dynamic" ValueToCompare='<%# DateTime.Today.ToShortDateString() %>'
                                           Type="Date" runat="server" ErrorMessage='<%#SysXUtils.GetMessage(ResourceConst.SUPPLIER_INFORMATION_LAST_BACKGROUND_CHECKED_DATE) %>'></asp:CompareValidator>
                                   </div>
                               </div>
    Now,if the user once entered the date and then tries to delete it,it is not working.I also tried to do this:
    DateInput-ReadOnly="false"
    EnableKeyboardNavigation="false"
    but if i do this then,if the user enters alphabet or Chars like -,/ it is giving error.
    I want that user cannot enter the date on its own,he has to pick it from the calender.
    any help would be deeply regarded.
  9. Pree
    Pree avatar
    3 posts
    Member since:
    Nov 2012

    Posted 28 Nov 2012 Link to this post

    hi Ty
    if i set the selecteddate property to null i"m getting the following exception:
    Cannot create an object of type 'System.DateTime' from its string representation 'null' for the 'SelectedDate' property.
  10. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 29 Nov 2012 Link to this post

    Hi Pree,

    Please note that custom created controls are not supported even when they are inherited directly from RadControls.

    Try using a default RadDatePicker declaration and see whether the issue still remains.

    All the best,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017