on page load, display Next Month calendar instead of current month

remya1000

Well-known member
Joined
Mar 29, 2007
Messages
122
Programming Experience
Beginner
i’m using ASP.NET.

i created a calendar, using the below code.

VB.NET:
<asp:Calendar id=Calendar1 runat="server"
                onselectionchanged="Date_Selected"
                DayNameFormat="Short"
                SelectionMode="DayWeek"
                Font-Names="Arial" Font-Size="12px"
                Height="180px" Width="200px"
                TodayDayStyle-Font-Bold="True"
                DayHeaderStyle-Font-Bold="True"
                OtherMonthDayStyle-ForeColor="gray"
                TitleStyle-BackColor="#3366ff"
                TitleStyle-ForeColor="white"
                TitleStyle-Font-Bold="True"
                SelectedDayStyle-BackColor="#ffcc66"
                SelectedDayStyle-Font-Bold="True"
                NextPrevFormat="ShortMonth"
                NextPrevStyle-ForeColor="white"
                NextPrevStyle-Font-Size="10px"
                SelectorStyle-BackColor="#99ccff"
                TodayDayStyle-BackColor="#99ccff"
                DayHeaderStyle-BackColor="#99ccff"
                SelectorStyle-ForeColor="navy"
                SelectorStyle-Font-Size="9px"
                SelectWeekText = "week"
                />
As normal when page load, it display a calendar with current month.

Is it possible, on page load to display Next Month calendar, instead of current month? After page load as usual, I need to navigate to previous months, next month and all, like normal calender. Only thing is to display Next month instead of current month on page load.

I tried this code
VB.NET:
Calendar1.TodaysDate = DateTime.Now.AddMonths(1)

But it’s not displaying the Next Month calendar instead of current month.

If you have any idea, how to do this, can you Please help me.

Thanks in advance...
 
Its working by using this code....

VB.NET:
        If Not Page.IsPostBack Then
        Else
                Calendar1.TodaysDate = DateTime.Now.AddMonths(1)
                Calendar1.SelectedDate = DateTime.Now.AddMonths(1)
                Calendar1.VisibleDate = Calendar1.SelectedDate
        End If
 
Back
Top