设置最小和最大的日历日期? [英] Setting minimum and maximum date on Calendar?
本文介绍了设置最小和最大的日历日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个环顾四周,再次,找不到如何设置允许在ASP.net日历用VB选择的最小和最大的日期。
I've had a look around, once again and can't find how to set the minimum and maximum dates allowed to be selected on a calendar in ASP.net with VB.
我使用Visual Studio 2010和它只是此刻定期日历控件...
I'm using Visual Studio 2010 and it's just a regular Calendar control at the moment...
目前,我已经看到了这样的话:
At the moment I've seen things like:
Calendar1.DateMin = DateTime.Now
但是,Visual Basic中似乎并不喜欢(也许这是一个C#的东西?)......总之,如果有一种方法可以做到这一点,将是一个很大的帮助!
But Visual Basic doesn't seem to like that (maybe it's a C# thing?)... Anyway, if there's a way to do this it'll be a great help!
推荐答案
您需要处理日历的的 的DayRender
事件:
You need to handle the Calendar's DayRender
event:
Private MinDate As Date = Date.MinValue
Private MaxDate As Date = Date.MaxValue
Protected Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs)Handles Calendar1.DayRender
If e.Day.Date < MinDate OrElse e.Day.Date > MaxDate Then
e.Day.IsSelectable = False
End If
End Sub
然后你可以在设置例如的Page_Load
:
MinDate = Date.Today
MaxDate = MinDate.AddDays(7)
这篇关于设置最小和最大的日历日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文