ASP Ajax 日历扩展器和显示时间

发布于 2024-07-08 12:28:59 字数 196 浏览 6 评论 0原文

我正在使用 Ajax Control Toolkit Calendar Extender 控件。 在某些字段中,我想显示时间和日期。 我尝试将格式设置为“dd/MM/yyyy hh:mm:ss”,但时间部分被擦除。 如果用户想要更改时间部分,他们可以手动执行此操作,日历下拉列表仅用于更改日期部分。

是否有任何解决方法或替代方案可以使其正常工作?

I am using the Ajax Control Toolkit Calendar Extender control. In some fields though I want to display the time along with the date. I have tried just setting the Format to "dd/MM/yyyy hh:mm:ss" but the time section gets wiped off. If the user wants to change the time section they can do it manually, the calendar drop down is only used for changing the date part.

Are there any workarounds or alternatives to get this working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

甜柠檬 2024-07-15 12:28:59

我有一个类似的问题,我计划使用日期字段和关联的时间下拉列表(以 1/2 小时增量)。 用户可以选择使用日历控件在日期字段中设置日期,然后下拉至有效时间。 我计划在时间下拉列表中选择一个“不关心”,以防它是“全天”事件。

[编辑] 我发现这个 jquery 插件 我最终可能会使用它。 我还在 Gaia DateTimePicker 的答案中找到了一个链接https://stackoverflow.com/questions/279766/datetimepicker-control">这篇文章(现在看起来已被删除,可能是因为OP要求WPF控件,而不是Web控件)。

I have a similar issue and I'm planning to use a Date field and an associated time dropdown (in 1/2 hour increments). User sets the date in the date field, optionally using the calendar control, and pulls down to a valid time. I plan to have one selection in the time drop down be a "don't care" in case it an "all day" event.

[EDIT] I found this jquery plugin that I may end up using. I also found a link to Gaia DateTimePicker in the answers to this post (which now looks to be deleted, probably because the OP was asking for WPF controls, not web controls).

ι不睡觉的鱼゛ 2024-07-15 12:28:59

Ra-Ajax 日历 将于本周五(28 日)推出,并提供 TIME 支持2008 年 11 月)并且获得 LGPL 许可...

The Ra-Ajax Calendar is coming out with TIME support this upcoming Friday (28th of Nov. 2008) and it's LGPL licensed...

丑疤怪 2024-07-15 12:28:59

基于CalendarExtender,您可以将格式设置为“MM/dd/yyyy”。 用户在日历中选择日期后,将返回例如 04/28/2009。 在日期选择事件中,您可以在返回的日期后附加当前时间。

OnClientDateSelectionChanged =“日期选择”

    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")
    }

Based on CalendarExtender, you can set the format as "MM/dd/yyyy". After the user select the date in calendar, it will return 04/28/2009 for example. In the date selected event, you can append the current time after the date 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")
    }
悸初 2024-07-15 12:28:59

将时间组件添加到 AjaxControlToolKit CalendarExtender 的唯一方法是使用 OnClientDateSelectionChanged 和 JavaScript 附加它。

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

<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>

The only way to add time component to the AjaxControlToolKit CalendarExtender, 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 tt");
    }
    </script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文