c# - Custom NextMonth CallenderControll button bug -
so need make custom next/prev button , got work jsut has litle problem displaying right number in label reason shows day before 1 callender showing if december display 11th in label think postback cant figure out after hours of frustration im gonna try , ask here have far
source code backend
private int month; private int year; private datetime date; void dayrender(object source, dayrendereventargs e) { // change background color of days in month // yellow. if (!e.day.isothermonth && !e.day.isweekend) e.cell.backcolor = system.drawing.color.yellow; // add custom text cell in calendar control. if (e.day.date.day == 18) e.cell.controls.add(new literalcontrol("<br />holiday")); } protected void page_load(object sender, eventargs e) { if (!ispostback) { date = datetime.now; calendrier.visibledate = date; month = date.month; session["month"] = month; year = date.year; } monthlabel.text = session["month"].tostring(); } // when next button being clicked protected void nextmonth_command(object sender, commandeventargs e) { int sessionmonth; sessionmonth = convert.toint32(session["month"]); sessionmonth++; session["month"] = sessionmonth; changecallender(2000, sessionmonth); } // method add date callender private void changecallender(int year, int month) { datetime date = new datetime(year , month, 1); calendrier.visibledate = date; }
Comments
Post a Comment