protected override void RenderContents(HtmlTextWriter output)
        {
            int indent = output.Indent;

            List <ContentDateLinks> lstCalendar = GetMetaInfo();

            output.Indent = indent + 3;
            output.WriteLine();

            string sCSS = "";

            if (!String.IsNullOrEmpty(CssClass))
            {
                sCSS = " class=\"" + CssClass + "\" ";
            }

            string sCSSClassTable = "";

            if (!String.IsNullOrEmpty(CSSClassTable))
            {
                sCSSClassTable = " class=\"" + CSSClassTable + "\" ";
            }
            string sCSSClassCaption = "";

            if (!String.IsNullOrEmpty(CSSClassCaption))
            {
                sCSSClassCaption = " class=\"" + CSSClassCaption + "\" ";
            }
            string sCSSClassDayHead = "";

            if (!String.IsNullOrEmpty(CSSClassDayHead))
            {
                sCSSClassDayHead = " class=\"" + CSSClassDayHead + "\" ";
            }
            string sCSSClassTableBody = "";

            if (!String.IsNullOrEmpty(CSSClassTableBody))
            {
                sCSSClassTableBody = " class=\"" + CSSClassTableBody + "\" ";
            }
            string sCSSClassDateLink = "";

            if (!String.IsNullOrEmpty(CSSClassDateLink))
            {
                sCSSClassDateLink = " class=\"" + CSSClassDateLink + "\" ";
            }
            string sCSSClassTableFoot = "";

            if (!String.IsNullOrEmpty(CSSClassTableFoot))
            {
                sCSSClassTableFoot = " class=\"" + CSSClassTableFoot + "\" ";
            }

            ContentDateTally lastMonth = new ContentDateTally {
                GoLiveDate = ThisMonth.AddMonths(-1), TheSite = SiteData.CurrentSite
            };
            ContentDateTally nextMonth = new ContentDateTally {
                GoLiveDate = ThisMonth.AddMonths(1), TheSite = SiteData.CurrentSite
            };

            output.WriteLine("<div" + sCSS + " id=\"" + this.ClientID + "\"> ");
            output.Indent++;

            if (!String.IsNullOrEmpty(CalendarHead))
            {
                output.WriteLine("<h2 class=\"calendar-caption\">" + CalendarHead + "  </h2> ");
            }

            DateTime FirstOfMonth = ThisMonth.AddDays(1 - ThisMonth.Day);
            int      iFirstDay    = (int)FirstOfMonth.DayOfWeek;
            TimeSpan ts           = FirstOfMonth.AddMonths(1) - FirstOfMonth;
            int      iDaysInMonth = ts.Days;

            int YearNumber  = FirstOfMonth.Date.Year;
            int MonthNumber = FirstOfMonth.Date.Month;

            int iDayOfWeek = 6;
            int DayOfMonth = 1;

            DayOfMonth -= iFirstDay;
            int WeekNumber = 1;

            output.WriteLine("	<table "+ sCSSClassTable + "> ");
            output.WriteLine("		<caption id=\""+ this.ClientID + "-caption\"  " + sCSSClassCaption + "> " + ThisMonth.Date.ToString("MMMM yyyy") + " </caption>");

            output.WriteLine("	<thead id=\""+ this.ClientID + "-head\" " + sCSSClassDayHead + ">");
            output.WriteLine("		<tr>");
            output.WriteLine("			<th scope=\"col\">SU</th>");
            output.WriteLine("			<th scope=\"col\">M</th>");
            output.WriteLine("			<th scope=\"col\">TU</th>");
            output.WriteLine("			<th scope=\"col\">W</th>");
            output.WriteLine("			<th scope=\"col\">TR</th>");
            output.WriteLine("			<th scope=\"col\">F</th>");
            output.WriteLine("			<th scope=\"col\">SA</th>");
            output.WriteLine("		</tr>");
            output.WriteLine("	</thead>");

            output.WriteLine("		<tbody id=\""+ this.ClientID + "-body\"  " + sCSSClassTableBody + ">");
            while ((DayOfMonth <= iDaysInMonth) && (DayOfMonth <= 31) && (DayOfMonth >= -7))
            {
                for (int DayIndex = 0; DayIndex <= iDayOfWeek; DayIndex++)
                {
                    if (DayIndex == 0)
                    {
                        output.WriteLine("			<tr id=\""+ this.ClientID + "-week" + WeekNumber.ToString() + "\"> ");
                        WeekNumber++;
                    }

                    DateTime cellDate = DateTime.MinValue;

                    if ((DayOfMonth >= 1) && (DayOfMonth <= iDaysInMonth))
                    {
                        cellDate = new DateTime(YearNumber, MonthNumber, DayOfMonth);

                        string sTD = "<td";
                        if (cellDate.Date == SiteData.CurrentSite.Now.Date)
                        {
                            sTD = "<td id=\"today\"";
                        }

                        ContentDateLinks cal = (from n in lstCalendar
                                                where n.PostDate.Date == cellDate.Date
                                                select n).FirstOrDefault();
                        if (cal != null)
                        {
                            output.WriteLine("			"+ sTD + " " + sCSSClassDateLink + ">");
                            output.WriteLine("				<a href=\""+ cal.MetaInfoURL + "\"> " + cellDate.Day.ToString() + " </a>");
                        }
                        else
                        {
                            output.WriteLine("			"+ sTD + ">");
                            output.WriteLine("				"+ cellDate.Day.ToString() + " ");
                        }
                        output.WriteLine("			</td>");
                    }
                    else
                    {
                        output.WriteLine("			<td class=\"pad\"> </td>");
                    }

                    DayOfMonth++;

                    if (DayIndex == iDayOfWeek)
                    {
                        output.WriteLine("		</tr>");
                    }
                }
            }
            output.WriteLine("		</tbody>");

            // as a bot crawler abuse stopper

            output.WriteLine("		<tfoot id=\""+ this.ClientID + "-foot\" " + sCSSClassTableFoot + ">");
            output.WriteLine("		<tr>");
            output.WriteLine("			<td colspan=\"3\" id=\"prev\" class=\"cal-prev\">");
            if (lastMonth.GoLiveDate >= SiteData.CurrentSite.Now.AddYears(-5))
            {
                output.WriteLine("				<a href=\""+ lastMonth.MetaInfoURL + "\">&laquo; " + lastMonth.GoLiveDate.ToString("MMM") + "</a>");
            }
            output.WriteLine("			</td>");
            output.WriteLine("			<td class=\"pad\"> &nbsp; </td>");
            output.WriteLine("			<td colspan=\"3\" id=\"next\" class=\"cal-prev\">");
            if (nextMonth.GoLiveDate <= SiteData.CurrentSite.Now.AddYears(5))
            {
                output.WriteLine("				<a href=\""+ nextMonth.MetaInfoURL + "\">" + nextMonth.GoLiveDate.ToString("MMM") + " &raquo;</a>");
            }
            output.WriteLine("			</td>");
            output.WriteLine("		</tr>");
            output.WriteLine("		</tfoot>");

            output.WriteLine("	</table>");

            output.Indent--;
            output.WriteLine("</div> ");
            output.Indent = indent;
        }
        public string ToHtmlString()
        {
            StringBuilder sb = new StringBuilder();

            List <ContentDateLinks> lstCalendar = GetDates();

            sb.AppendLine();

            string sCSS = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClass))
            {
                sCSS = " class=\"" + this.CssClass + "\" ";
            }

            string sCssClassTable = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClassTable))
            {
                sCssClassTable = " class=\"" + this.CssClassTable + "\" ";
            }
            string sCssClassCaption = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClassCaption))
            {
                sCssClassCaption = " class=\"" + this.CssClassCaption + "\" ";
            }
            string sCssClassDayHead = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClassDayHead))
            {
                sCssClassDayHead = " class=\"" + this.CssClassDayHead + "\" ";
            }
            string sCssClassTableBody = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClassTableBody))
            {
                sCssClassTableBody = " class=\"" + this.CssClassTableBody + "\" ";
            }
            string sCssClassDateLink = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClassDateLink))
            {
                sCssClassDateLink = " class=\"" + this.CssClassDateLink + "\" ";
            }
            string sCssClassTableFoot = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClassTableFoot))
            {
                sCssClassTableFoot = " class=\"" + this.CssClassTableFoot + "\" ";
            }

            ContentDateTally lastMonth = new ContentDateTally {
                TallyDate = this.ThisMonth.AddMonths(-1), TheSite = SiteData.CurrentSite
            };
            ContentDateTally nextMonth = new ContentDateTally {
                TallyDate = this.ThisMonth.AddMonths(1), TheSite = SiteData.CurrentSite
            };

            sb.AppendLine("<div" + sCSS + " id=\"" + this.ElementId + "\"> ");

            if (!String.IsNullOrEmpty(this.CalendarHead))
            {
                sb.AppendLine("<h2 class=\"calendar-caption\">" + this.CalendarHead + "  </h2> ");
            }

            DateTime firstOfMonth = this.ThisMonth.AddDays(1 - this.ThisMonth.Day);
            int      firstDay     = (int)firstOfMonth.DayOfWeek;
            TimeSpan ts           = firstOfMonth.AddMonths(1) - firstOfMonth;
            int      daysInMonth  = ts.Days;

            int yearNumber  = firstOfMonth.Date.Year;
            int monthNumber = firstOfMonth.Date.Month;

            int weekNumber = 1;
            int dayOfWeek  = 6;
            int dayOfMonth = 1;

            dayOfMonth -= firstDay;

            sb.AppendLine("	<table " + sCssClassTable + "> ");
            sb.AppendLine("		<caption id=\""+ this.ElementId + "-caption\"  " + sCssClassCaption + "> " + this.ThisMonth.Date.ToString("MMMM yyyy") + " </caption>");

            sb.AppendLine("	<thead id=\"" + this.ElementId + "-head\" " + sCssClassDayHead + ">");
            sb.AppendLine("		<tr>");
            sb.AppendLine("			<th scope=\"col\">SU</th>");
            sb.AppendLine("			<th scope=\"col\">M</th>");
            sb.AppendLine("			<th scope=\"col\">TU</th>");
            sb.AppendLine("			<th scope=\"col\">W</th>");
            sb.AppendLine("			<th scope=\"col\">TR</th>");
            sb.AppendLine("			<th scope=\"col\">F</th>");
            sb.AppendLine("			<th scope=\"col\">SA</th>");
            sb.AppendLine("		</tr>");
            sb.AppendLine("	</thead>");

            sb.AppendLine("		<tbody id=\""+ this.ElementId + "-body\"  " + sCssClassTableBody + ">");
            while ((dayOfMonth <= daysInMonth) && (dayOfMonth <= 31) && (dayOfMonth >= -7))
            {
                for (int DayIndex = 0; DayIndex <= dayOfWeek; DayIndex++)
                {
                    if (DayIndex == 0)
                    {
                        sb.AppendLine("			<tr id=\""+ this.ElementId + "-week" + weekNumber.ToString() + "\"> ");
                        weekNumber++;
                    }

                    DateTime cellDate = DateTime.MinValue;

                    if ((dayOfMonth >= 1) && (dayOfMonth <= daysInMonth))
                    {
                        cellDate = new DateTime(yearNumber, monthNumber, dayOfMonth);

                        string sTD = "<td";
                        if (cellDate.Date == SiteData.CurrentSite.Now.Date)
                        {
                            sTD = "<td id=\"today\"";
                        }

                        ContentDateLinks cal = (from n in lstCalendar
                                                where n.PostDate.Date == cellDate.Date
                                                select n).FirstOrDefault();
                        if (cal != null)
                        {
                            sb.AppendLine("			"+ sTD + " " + sCssClassDateLink + ">");
                            sb.AppendLine("				<a href=\""+ cal.DateURL + "\"> " + cellDate.Day.ToString() + " </a>");
                        }
                        else
                        {
                            sb.AppendLine("			"+ sTD + ">");
                            sb.AppendLine("				"+ cellDate.Day.ToString() + " ");
                        }
                        sb.AppendLine("			</td>");
                    }
                    else
                    {
                        sb.AppendLine("			<td class=\"pad\"> </td>");
                    }

                    dayOfMonth++;

                    if (DayIndex == dayOfWeek)
                    {
                        sb.AppendLine("		</tr>");
                    }
                }
            }
            sb.AppendLine("		</tbody>");

            // as a bot crawler abuse stopper

            sb.AppendLine("		<tfoot id=\""+ this.ElementId + "-foot\" " + sCssClassTableFoot + ">");
            sb.AppendLine("		<tr>");
            sb.AppendLine("			<td colspan=\"3\" id=\"prev\" class=\"cal-prev\">");
            if (lastMonth.TallyDate >= SiteData.CurrentSite.Now.AddYears(-3))
            {
                sb.AppendLine("				<a href=\""+ lastMonth.DateURL + "\">&laquo; " + lastMonth.TallyDate.ToString("MMM") + "</a>");
            }
            sb.AppendLine("			</td>");
            sb.AppendLine("			<td class=\"pad\"> &nbsp; </td>");
            sb.AppendLine("			<td colspan=\"3\" id=\"next\" class=\"cal-prev\">");
            if (nextMonth.TallyDate <= SiteData.CurrentSite.Now.AddYears(3))
            {
                sb.AppendLine("				<a href=\""+ nextMonth.DateURL + "\">" + nextMonth.TallyDate.ToString("MMM") + " &raquo;</a>");
            }
            sb.AppendLine("			</td>");
            sb.AppendLine("		</tr>");
            sb.AppendLine("		</tfoot>");

            sb.AppendLine("	</table>");

            sb.AppendLine("</div> ");

            return(sb.ToString());
        }