Edit this page

DefaultViewChanged

The RadCalendar 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:

  1. The RadCalendarcontrol whose view was just changed. This argument is of type object, but can be cast to the RadCalendar type.

  2. 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;
}
Protected Sub RadCalendar1_DefaultViewChanged(ByVal sender As Object, ByVal e As DefaultViewChangedEventArgs) Handles RadCalendar1.DefaultViewChanged
    If e.OldView.ViewStartDate < e.NewView.ViewStartDate Then
        Label1.Text = e.OldView.TitleContent + " -> " + e.NewView.TitleContent
    Else
        Label1.Text = e.NewView.TitleContent + " <- " + e.OldView.TitleContent
    End If
End Sub

See Also