No, you cannot easily modify an existing calendar. But perhaps this is enough to declare a column above the calendar where you can select the year.
<table> <tr> <td> <asp:DropDownList id="drpCalMonth" Runat="Server" OnSelectedIndexChanged="Set_Calendar" AutoPostBack="true"></asp:DropDownList> <asp:DropDownList id="drpCalYear" Runat="Server" OnSelectedIndexChanged="Set_Calendar" AutoPostBack="true"></asp:DropDownList> </td> </tr> <tr> <td> <asp:Calendar id="cntCalendar" Runat="Server" Width="100%" /> </td> </tr> </table>
Here are two methods to fill in summer and monthly dropdownlists:
protected void Populate_MonthList() {
You can initialize lists from Page_Load :
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Populate_MonthList(); Populate_YearList(); } }
and finally, here is the event handler for the SelectedIndexChanged event for DropDownLists , which sets the new Date :
protected void Set_Calendar(object Sender, EventArgs e) { int year = int.Parse(drpCalYear.SelectedValue); int month = int.Parse(drpCalMonth.SelectedValue); cntCalendar.TodaysDate = new DateTime(year, month, 1); }
[verified]
Inspired by: http://www.4guysfromrolla.com/articles/090104-1.aspx (VB)
source share