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.
我再次浏览一下,无法找到如何设置允许在ASP.net中使用VB在日历上选择的最小和最大日期。
I'm using Visual Studio 2010 and it's just a regular Calendar control at the moment...
我正在使用Visual Studio 2010,它只是一个常规的日历控件...
At the moment I've seen things like:
目前我见过的事情如下:
Calendar1.DateMin = DateTime.Now
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!
但Visual Basic似乎并不喜欢(也许它是C#的东西?)......无论如何,如果有办法做到这一点,那将是一个很大的帮助!
1 个解决方案
#1
12
You need to handle the Calendar's DayRender
event:
您需要处理Calendar的DayRender事件:
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
Then you can set it for example in Page_Load
:
然后你可以在Page_Load中设置它:
MinDate = Date.Today
MaxDate = MinDate.AddDays(7)
#1
12
You need to handle the Calendar's DayRender
event:
您需要处理Calendar的DayRender事件:
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
Then you can set it for example in Page_Load
:
然后你可以在Page_Load中设置它:
MinDate = Date.Today
MaxDate = MinDate.AddDays(7)