日历控件:在页面加载时选择今天的日期
我在 asp .net webform 上有一个日历控件。在 Pag_Load 事件中,我
this.CalendarReportDay.SelectedDate = DateTime.Now;
设置了日历的选定日期,但今天的日期未在日历上突出显示。
有谁知道如何选择今天的日期?
I have a calendar control on a asp .net webform. In the Pag_Load event I have
this.CalendarReportDay.SelectedDate = DateTime.Now;
Which sets the Calendar's Selected Date but todays date is not highlighted on the calendar.
Does anyone know how to get todays date to be selected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须
在末尾设置 Date 属性,这一点很重要,否则 DateTime.Now 的时间部分将阻止选择。然后它获取应用的 SelectedDayStyle, fe
You have to set
The Date property at the end is important, otherwise the time component of DateTime.Now will prevent the selection. Then it gets the applied SelectedDayStyle, f.e.
SelectedDate
将设置日历的日期,但这并不意味着它将突出显示它。一个问题是
DateTime.Now
包含时间,而日历只需要日期即可按预期工作,因此您可以使用DateTime.Today
代替,例如显示日期(即让日历显示显示所选日期所需的正确月份和年份)使用
VisibleDate
,例如有关更多详细信息,请查看:
http://www.devtoolshed.com/content/how-highlight-day-aspnet-calendar -control-selecteddate-property
SelectedDate
will set the calendar's date, but that does not mean it will highlight it.One issue is that
DateTime.Now
includes the time whereas the calendar needs ONLY the date to work as expected, so you can useDateTime.Today
instead, e.g.To show the date (i.e. to get the calendar to display the correct month and year needed to show the selected date) use
VisibleDate
, e.g.For more details, have a look at:
http://www.devtoolshed.com/content/how-highlight-day-aspnet-calendar-control-selecteddate-property