ASP Ajax Calendar Extender and Time Display

I am using the Ajax Control Toolkit Calendar Extender element. In some areas, although I want to display the time along with the date. I tried just setting the format "dd / MM / yyyy hh: mm: ss", but the time section is erased. If the user wants to change the time section, he can do it manually, the drop-down calendar is used only to change the date.

Are there any workarounds or alternatives to make this work?

+3
source share
4 answers

I have a similar problem and I plan to use the Date field and its associated time (in 1/2 hour increments). The user sets the date in the date field, optionally using the calendar control, and extends it to the valid time. I plan that one of the options in the drop-down list will be "don't care" if it is an "all day" event.

[EDIT] I found this jquery plugin that I can use. I also found a link to the Gaia DateTimePicker in the answers to this post (which now seems to be deleted, probably because the OP was requesting WPF controls, not web controls).

+5
source

Ra-Ajax TIME (28 2008 ) LGPL...

+2

Based on CalendarExtender, you can set the format as "MM / dd / yyyy". After the user selects a date in the calendar, he will return, for example, 04/28/2009. In the selected date event, you can add the current time after the date is returned.

OnClientDateSelectionChanged = "dateselect"

    function dateselect(ev)
    {
        var calendarBehavior1 = $find("Calendar1");
        var d = calendarBehavior1._selectedDate;
        var now = new Date();
        calendarBehavior1.get_element().value = d.format("MM/dd/yyyy") + " "+now.format("HH:mm:ss")
    }
+1
source

The only way to add a time component to the AjaxControlToolKit CalendarExtender is to add 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 tt");
    }
    </script>
0
source

Source: https://habr.com/ru/post/1699390/


All Articles