Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

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: 3.0/5 (4 votes cast)