Need to cancel the RadDatePicker OnDateSelected after setting date in javascript

2 posts, 0 answers
  1. Michael Hunt
    Michael Hunt avatar
    42 posts
    Member since:
    Aug 2009

    Posted 02 Oct 2009 Link to this post

    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
  2. Dimo
    Admin
    Dimo avatar
    8456 posts

    Posted 05 Oct 2009 Link to this post

    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.
Back to Top