System.Web.UI.WebControls.Calendar.WriteDays C# (CSharp) Method

WriteDays() private method

private WriteDays ( System.Web.UI.HtmlTextWriter writer, bool enabled ) : void
writer System.Web.UI.HtmlTextWriter
enabled bool
return void
		void WriteDays (HtmlTextWriter writer, bool enabled)
		{
			DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date
			DateTime lastDate;
			TableCell selectorCell = null;
			int n;

			// Goes backwards until we find the date of that is begining of the week
			for (n = 0; n < daysInAWeek; n++) {
				if (date.DayOfWeek == DisplayFirstDayOfWeek)
					break;

				date = GetGlobalCalendar().AddDays (date, -1);
			}
			/* if the start date is the first day of the week, we need to shift backward one more week */
			if (n == 0)
				date = GetGlobalCalendar().AddDays (date, -1 * daysInAWeek);

			lastDate = GetGlobalCalendar().AddDays (date, 6 * daysInAWeek); // Always six weeks per months

			while (true) {
				writer.RenderBeginTag (HtmlTextWriterTag.Tr);

				if (HasWeekSelectors (SelectionMode)) {	// Week selector
					if (selectorCell == null) {
						selectorCell = new TableCell ();
						selectorCell.ApplyStyle (SelectorStyle);
						selectorCell.HorizontalAlign = HorizontalAlign.Center;
						selectorCell.Width = Unit.Percentage (GetCellWidth ());
					}

					selectorCell.RenderBeginTag (writer);
					writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, enabled));
					selectorCell.RenderEndTag (writer);
				}

				for (int i = 0; i < daysInAWeek; i++) {
					WriteDay (date, writer, enabled);
					date = GetGlobalCalendar().AddDays (date, 1);
				}

				writer.RenderEndTag ();
				if (date >= lastDate)
					break;
			}
		}