catching the next month click of a calendar control


say i have two calendar controls on a page.

when the user clicks calendar 1's next month button i also want it to change calendar 2's month to the next month.

is this possible?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Luis PérezSoftware Architect in .NetCommented:
When the user changes the visible month of the first calendar, the event VisibleMonthChanged fires on the server. The "e" parameter of the VisibleMonthChanged event offers NewDate and PreviousDate properties to control where the calendar are and where are going to. You can then act on the VisibleDate property of the second calendar. The VisibleDate property establish the month that is shown on the calendar. If you set the VisibleDate property of a Calendar control to any date, the calendar will show the month/year of that date (no matters the dat part of the date passed).

For example, this simple snippet mantains synchronized two calendar controls in order that both always keep shown the same month/year:
Protected Sub Calendar1_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) Handles Calendar1.VisibleMonthChanged
    'Set the Calendar2 VisibleDate property to the
    'NewDate property of this Calendar, so both keep
    'synchronized on the visible month
    Me.Calendar1.VisibleDate = e.NewDate
End Sub

Hope that helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In VisibleMonthChanged event of your first calendar add this

protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
            Calendar2.VisibleDate = e.NewDate;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.