ajaxToolkit:CalendarExtender Time Component

2.2k Views Asked by At

I am using ajaxToolkit:CalendarExtender with a TextBox and I want users to also be able to input the time component.

Whats the best way to do this?

1

There are 1 best solutions below

0
On

A way to "force" the AjaxControlToolKit CalendarExtender to use a time component, is to append it using OnClientDateSelectionChanged and JavaScript.

<ajaxToolkit:CalendarExtender ID="ce1" runat="server" PopupButtonID="calImg" Enabled="true" Format="dd/MM/yyyy" TargetControlID="txtLeft" PopupPosition="TopRight" OnClientDateSelectionChanged="AppendTime"></ajaxToolkit:CalendarExtender>

and

<script language="javascript" type="text/javascript">
        //this script will get the date selected from the given calendarextender (ie: "sender") and append the
        //current time to it.
        function AppendTime(sender, args){
            var selectedDate = new Date();
            selectedDate = sender.get_selectedDate();
            var now = new Date();
            sender.get_element().value = selectedDate.format("dd/MM/yyyy") + " " + now.format("HH:mm");
        }
    </script>