Asp.net 日历在页面加载事件中选择当前星期
在 Page_Load 事件中,我希望在日历上选择当前的一周,而不仅仅是当前的一天。这怎么能做到呢?
<asp:Calendar
ID="Calendar1"
runat="server"
ondayrender="Calendar1_DayRender"
SelectionMode="DayWeek"
onselectionchanged="Calendar1_SelectionChanged">
</asp:Calendar>
protected void Page_Load(object sender, EventArgs e)
{
Calendar1.SelectedDate = System.DateTime.Today;
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
e.Day.IsSelectable = false;
}
In the Page_Load event I would like to have the current week selected on the calendar instead of just the current day. How can this be done?
<asp:Calendar
ID="Calendar1"
runat="server"
ondayrender="Calendar1_DayRender"
SelectionMode="DayWeek"
onselectionchanged="Calendar1_SelectionChanged">
</asp:Calendar>
protected void Page_Load(object sender, EventArgs e)
{
Calendar1.SelectedDate = System.DateTime.Today;
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
e.Day.IsSelectable = false;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下:
Give this a try: