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.
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
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!
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
Then you can set it for example in Page_Load
:
MinDate = Date.Today
MaxDate = MinDate.AddDays(7)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With