[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 811
  • Last Modified:

catching the next month click of a calendar control

hi,

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?
0
scm0sml
Asked:
scm0sml
2 Solutions
 
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.
0
 
tiagosalgadoCommented:
In VisibleMonthChanged event of your first calendar add this

protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
        {
            Calendar2.VisibleDate = e.NewDate;
        }
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now