DatePopupButton

2 posts, 0 answers
  1. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 12 Nov 2011 Link to this post

    Hi All

    I have a RadDateTime Picker which is enabled / disabled based on the value of a checkbox,
    I have just changed the enable disable event from server side to client side, this has caused a problem with the onclick event that i add to the DatePopUpButton on Page Load server side?
    Page Load:
      
    RadDateTimePicker1.DatePopupButton.Attributes.Add("onclick","Myevent(event, '" + RadDateTimePicker1.ClientID + "');return false;")
      
    function Myevent(e, pickerID) {
        var datePicker;
        datePicker = $find(pickerID);
      
        var textBox = datePicker.get_textBox();
        var popupElement = datePicker.get_popupContainer();
      
        var dimensions = datePicker.getElementDimensions(popupElement);
        var position = datePicker.getElementPosition(textBox);
        var popOffset = (dimensions.height - position.y)
                              
        if (popOffset <= 0) {
                              
            datePicker.showPopup(position.x, position.y - dimensions.height);
      
        } else {
                                  
            datePicker.showPopup(position.x, position.y - dimensions.height + popOffset);
        }
      
    }

    The problem is that now when the DatePopupButton is clicked the calendar momentarily appear then disappear??

    I have seen another post HERE with a similar problem however i would rathe not use this solution as i want to use the approach that i already have as i have found this more reliable.

    Does anybody have any idea why this is happening and how i can cure it please?

    Many Thanks

    Best Regards

    Cush
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Nov 2011 Link to this post

    Hello ,

    You can add togglePopup to the javascript. Here is the sample code.

    JS:
    <script type="text/javascript">
    function Myevent()
         {
           var datePicker;
           datePicker = $find("<%=RadDateTimePicker1.ClientID %>");
           var textBox = datePicker.get_textBox();
           var popupElement = datePicker.get_popupContainer();
           var dimensions = datePicker.getElementDimensions(popupElement);
           var position = datePicker.getElementPosition(textBox);
           var popOffset = (dimensions.height - position.y)
           if (popOffset <= 0)
           {
              datePicker.showPopup(position.x, position.y - dimensions.height);
              datePicker.togglePopup();
          }
          else
           {
              datePicker.showPopup(position.x, position.y - dimensions.height + popOffset);
              datePicker.togglePopup();
           }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top