Click here to Skip to main content
16,020,990 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to restrict selecting calender control before year 1900 and after year 2100. How can I do this. Please help me to solve this.
Posted
Comments
joshrduncan2012 31-Oct-12 9:27am    
What have you attempted so far? What language are you using? Please provide your existing code so we can better assist you.

1 solution

Check following links, these might help you:
Restrict-the-Calendar-selection-within-a-specific-range[^]
How to Disable Selected Dates dynamically from the Calendar Control[^]
http://forums.asp.net/t/1161833.aspx[^]

You can check if following code helps you, its in VB.Net, you can convert it to C# if that is your language:
VB
Private Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) 
   If e.Day.Date < BeginningOfDateRange 
     e.Cell.BackColor = System.Drawing.Color.LightGray 
     e.Day.IsSelectable = False 
   End If 
 
   If e.Day.Date > EndOfDateRange Then 
     e.Cell.BackColor = System.Drawing.Color.LightGray 
     e.Day.IsSelectable = False 
   End If 
End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900