Need to add a button for next previous year in ASP calendar control dynamically.
How can I add it right next to the existing next and prev controls? Is it possible to do this via dayrender event ?? Please help
The ASP.NET Web Forms DateTime Picker control is used to enter or select date and time values from a pop-up calendar and dropdown time list. It provides month, year, and decade views for quick navigation to the desired date.
Try the below...
<asp:Calendar ID="calender1" runat="server" VisibleDate="2012-10-10"></asp:Calendar>
<asp:Button ID="btnMNext" runat="server" Text="Next Month" />
<asp:Button ID="btnMPrev" runat="server" Text="Prev Month" />
<asp:Button ID="btnNextYr" runat="Server" Text="Next Year" />
<asp:Button ID="btnPrevYr" runat="server" Text="Prev Year" />
<br />
<asp:TextBox ID="txtcur" runat="server"></asp:TextBox>
in code behind
**btnMNext_Click**
String month;
month = calender1.SelectMonthText();
txtcur.Text = calender1.SelectedDate.ToShortDateString();
calender1.VisibleDate = calender1.VisibleDate.AddMonths(1);
**btnPrevYr_Click**
calender1.VisibleDate = calender1.VisibleDate.AddYears(-1);
**btnNextYr_Click**
calender1.VisibleDate = calender1.VisibleDate.AddYears(1);
End Sub
**btnMPrev_Click**
calender1.VisibleDate = calender1.VisibleDate.AddMonths(-1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With