IDoComeBy
IDoComeBy

Reputation: 21

Is that possible to add new next and previous button for asp:Calendar

The asp.Net Calendar provides Next and Previous buttons over the calendar day name but I don't like it. I am trying to add Next and Previous button outside the calendar just like the Google calendar. Then is it possible to add MonthChangedEventArgs to the button so I can use it just like OnVisibleMonthChanged provided by the asp.Net Calendar.

FYI: When you click on the next button then the month changes. Just like when you use e.NewDate and e.Previous from MonthChangedEventArgsDate and then use .VisibleDate to update the calendar

Upvotes: 2

Views: 1500

Answers (1)

JonH
JonH

Reputation: 33153

See this article, I was able to use it to create a drop down box allowing you to select a month. It is better then a button or hyperlink because I can go to December from February without that many clicks. Here is a screen shot:

enter image description here

Here is the article.

Here is a working demo for you

The code you are specifically after is:

public void Set_Calendar(object Sender, EventArgs E)
{
    cntCalendar.TodaysDate = Convert.ToDateTime(drpCalMonth.SelectedItem.Value + " 1, " + drpCalYear.SelectedItem.Value);
}

Upvotes: 2

Related Questions