gpt4 book ai didi

asp.net - 日历控件 : Have todays date selected on page load

转载 作者:行者123 更新时间:2023-12-02 11:24:58 25 4
gpt4 key购买 nike

我在 asp .net webform 上有一个日历控件。在 Pag_Load 事件中我有

this.CalendarReportDay.SelectedDate = DateTime.Now;

它设置日历的选定日期,但今天的日期不会在日历上突出显示。

有人知道如何选择今天的日期吗?

最佳答案

SelectedDate 将设置日历的日期,但这并不意味着它将突出显示它。

一个问题是 DateTime.Now 包含时间,而日历只需要日期即可按预期工作,因此您可以使用 DateTime.Today 代替,例如

myCalendar.SelectedDate = DateTime.Today

要显示日期(即让日历显示显示所选日期所需的正确月份和年份),请使用 VisibleDate,例如

myCalendar.VisibleDate = dateToUse;

有关更多详细信息,请查看:

http://www.devtoolshed.com/content/how-highlight-day-aspnet-calendar-control-selecteddate-property

关于asp.net - 日历控件 : Have todays date selected on page load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3400646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com