ASP.NET: Limit selections for the Calendar
From Wiki
Summary: Shows how to set the calendar control to only show certain months
Unlike the .NET windows Calendar control, the ASP.NET control doesn't allow you to set a maximum date for the control. The code below shows how you can limit the user to only go forward to a particular month (you could also adapt this example so the user can't go back beyond a previous month).
- Protected Sub Calendar1_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) _
- Handles Calendar1.VisibleMonthChanged
- If e.NewDate.Year = 2007 And e.NewDate.Month = 12 Then
- Calendar1.NextMonthText = ""
- Else
- Calendar1.NextMonthText = ">"
- End If
- End Sub
This Hack is part of the ASP.NET Hacks collection


