Search code examples
javascriptasp.netajaxcontroltoolkit

asp.net AjaxControlToolkit CalendarExtender: setting displayed month programmatically from client side


Is there a way to set the calendar extender, or a method I can call so it always displays the month containing the selected date when the target textbox is clicked? I have found the method to set the selected date, but this does not automatically bring the month of the selected date into view.


Solution

  • You can handle the onClientShown event:

    <cc1:calendarextender ID="Calendarextender1"
        OnClientShown="clientShown" ...
    

    For example:

    <script type="text/javascript">
        function clientShown(sender, args) {
            var extender= $find('Calendarextender1');
            sender.set_visibleDate(extender._selectedDate);
            // the following is just to show you some other interesting methods
            //sender.set_todaysDate(extender._selectedDate);
            //sender.set_selectedDate(extender._selectedDate);
        }
    </script>
    

    I'm afraid there's no documentation, so try them out.