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

UnSelect Date in Rad Date Time Picker

8 Answers 301 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
siva
Top achievements
Rank 1
siva asked on 24 Sep 2009, 03:17 PM
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>

 

8 Answers, 1 is accepted

Sort by
0
Ty
Top achievements
Rank 1
answered on 24 Sep 2009, 07:48 PM
To clear the datetimepicker set the SelectedDate property to null.
0
Shinu
Top achievements
Rank 2
answered on 25 Sep 2009, 06:26 AM
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.
0
siva
Top achievements
Rank 1
answered on 29 Sep 2009, 06:04 AM
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
0
Pree
Top achievements
Rank 1
answered on 23 Nov 2012, 08:37 AM
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
0
Eyup
Telerik team
answered on 28 Nov 2012, 07:05 AM
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.
0
Pree
Top achievements
Rank 1
answered on 28 Nov 2012, 07:44 AM
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.
0
Pree
Top achievements
Rank 1
answered on 28 Nov 2012, 07:49 AM
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.
0
Eyup
Telerik team
answered on 29 Nov 2012, 03:18 PM
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.
Tags
Calendar
Asked by
siva
Top achievements
Rank 1
Answers by
Ty
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
siva
Top achievements
Rank 1
Pree
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or