RadDatePicker OnDateSelected Loop

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    8 posts
    Member since:
    Mar 2009

    Posted 13 Jan 2010 Link to this post

    I have a RadDatePicker that if the user changes the date I have a confirm message to ask if the want to change the date.
    If they click no I want to change the date back to its original value.
    In my java script I have
    var datepicker = $find("datePicker");

    when I set the selected date the function is called again and I am stuck in an Infinate loop since everytime I am setting the selected date in javascript the function is calling its self. I just want it so that if the user clicks no that the date will not change. I haven't been able to find anything on this site to fix it.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Jan 2010 Link to this post

    Hello Ryan,

    Use a global variable in order to check whether it is entering for the second time in DateSelected event handler as shown below.

    <script type="text/javascript"
        var check = false
        function OnDateSelected(sender, args) { 
            if (!check) { 
                if (!confirm('do you want to change the date ?')) { 
                    check = true
                else { 
            check = false
    [Attach 'OnDateSelected' client event to RadDatePicker.]

Back to Top