Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

ASP.NET: Limit selections for the Calendar

From Wiki

Jump to: navigation, search

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).

  1. Protected Sub Calendar1_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) _
  2.    Handles Calendar1.VisibleMonthChanged
  3.     If e.NewDate.Year = 2007 And e.NewDate.Month = 12 Then
  4.         Calendar1.NextMonthText = ""
  5.     Else
  6.         Calendar1.NextMonthText = ">"
  7.     End If
  8. End Sub


This Hack is part of the ASP.NET Hacks collection

440 Rating: 5.0/5 (1 vote cast)