If you use the ASP.NET Calendar Control and want to hide the PrevMonthText or NextMonthText then you need to use the PreRender-Event from the Calendar-Control.
In this example I hide the PrevMonthText (Hyperlink) when the current year and month equals calendars visible year and month. Note: You must set/init the VisibileDate-Property in Page_Load-Event. In my example I want that the start month and year of the control is set to today.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MyCalendarControl.VisibleDate = DateTime.Now; } } protected void MyCalendarControl_PreRender(object sender, EventArgs e) { // hide previous month link in calendar when current month and year equals calendars month and year MyCalendarControl.PrevMonthText = DateTime.Now.Month == EventsCalendar.VisibleDate.Month && DateTime.Now.Year == EventsCalendar.VisibleDate.Year ? string.Empty : "<" } |