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

Need to cancel the RadDatePicker OnDateSelected after setting date in javascript

1 Answer 146 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Michael Hunt
Top achievements
Rank 1
Michael Hunt asked on 02 Oct 2009, 04:48 PM
Hi,

First let me say that I've seen this post at the following URL, and it won't do everything I need to do.

http://www.telerik.com/community/forums/aspnet-ajax/calendar/how-to-prevent-client-dateselected-from-being-fired.aspx

I have a RadDatePicker with a Calendar, and want to do the following:
 - Allow the user to change a date by editing the textbox of the RadDatePicker (and also via the calendar popup).
 - When they do change the date by editing the textbox of the RadDatePicker, I want to have a javascript function confirm that they really want to do this.
 - If they choose to Cancel, I want to reset the date in the RadDatePicker textbox back to its original value.

I can do all of that via a javascript function assigned to the OnDateSelected client side event.  But when I reset the date back to the original date using set_selectedDate, that of course causes the OnDateSelected event to fire again.  So in my case, I get another prompt asking them to confirm their actions.

Question:  How can I cancel the event before calling set_selectedDate, so the event doesn't fire again?
The workaround shown in the link above, does something in the popup opening event.  But that doesn't handle the case I'm talking about, where the user physically changes the date by typing in the textbox.

Thanks,
Brent

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 05 Oct 2009, 02:28 PM
Hello Michael,

You can use some global Javascript variable as a flag, to distinguish between the cases when you prompt the user to confirm his action and when the previous date is set. The "t" variable in the above forum thread is used for the same purpose.

Greetings,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Calendar
Asked by
Michael Hunt
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or