Link to home
Create AccountLog in
Avatar of DigiFoto
DigiFoto

asked on

How to set max/min year on ASP.Net calendar control

I need to set max/min year on a ASP.Net calendar control so that users cannot go beyond the set years.  How do you accomplish that?  thanks.
Avatar of ZachSmith
ZachSmith
Flag of United States of America image

You may be able to use the VisibleMonthChanged event. Like this:
    protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
    {
        if(e.NewDate < dateMin ||
            e.NewDate > dateMax)
        {
            Calendar1.VisibleDate = e.PreviousDate;
        }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ZachSmith
ZachSmith
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Did you get this to work?