DefaultViewChanged
The ASP NET AJAX Calendar control provides the DefaultViewChanged server event, which is raised when the AutoPostBack property is set to true, and the user changes the currently visible view using the navigation controls in the title bar.
The DefaultViewChanged event handler receives two arguments:
-
The RadCalendarcontrol whose view was just changed. This argument is of type object, but can be cast to the RadCalendar type.
-
A DefaultViewChangedEventArgs object. This object has the following two properties:
-
OldView is the CalendarView object for the view that was current before the change.
-
NewView is the CalendarView object for the current view after the change.
-
Use the DefaultViewChanged event handler to respond to changes in the dates the calendar displays:
protected void RadCalendar1_DefaultViewChanged(object sender, DefaultViewChangedEventArgs e)
{
if (e.OldView.ViewStartDate < e.NewView.ViewStartDate)
Label1.Text = e.OldView.TitleContent + " -> " + e.NewView.TitleContent;
else
Label1.Text = e.NewView.TitleContent + " <- " + e.OldView.TitleContent;
}