예제 #1
0
        public string GetCallbackResult()
        {
            //return string.Empty;
            ThemeHelper theme = new ThemeHelper(Theme);

            if (!Enabled)
            {
                return(string.Empty);
            }

            mv.Width       = DateBoxWidth;
            mv.BorderStyle = BorderStyle.None;
            mv.ShowTitle   = false;
            mv.DayRender  += MonthViewDayRender;

            mv.Font.Name = "Tahoma";
            mv.DayStyle.MergeWith(theme.DayStyle);
            mv.DayHeaderStyle.MergeWith(theme.DayStyle);
            mv.SelectedDayStyle.MergeWith(theme.SelectedDayStyle);
            mv.TodayDayStyle.MergeWith(theme.TodayDayStyle);

            //next & prev formats

            DropDownList list = theme.CreateFooterDropDownList();
            //list.MergeStyle(monthYearDropDownStyle);


            StringBuilder  sb     = new StringBuilder();
            StringWriter   writer = new StringWriter(sb);
            HtmlTextWriter tw     = new HtmlTextWriter(writer);

            if (this.EnableDropShadow)
            {
                tw.AddStyleAttribute(HtmlTextWriterStyle.Display, "#EFEFEF");
            }
            tw.AddAttribute(HtmlTextWriterAttribute.Id, "FADatePickerDropShadow_" + this.ClientID);
            tw.AddStyleAttribute(HtmlTextWriterStyle.ZIndex, (this.ZIndex + 1).ToString());
            tw.AddStyleAttribute(HtmlTextWriterStyle.Left, this.CalendarOffsetX.ToString());
            tw.AddStyleAttribute(HtmlTextWriterStyle.Top, this.CalendarOffsetY.ToString());
            tw.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline");
            tw.AddStyleAttribute("min-width", this.mv.Width.ToString());
            tw.AddAttribute("CellPadding", "0");
            tw.AddAttribute("CellSpacing", "0");
            tw.RenderBeginTag(HtmlTextWriterTag.Table);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            tw.RenderBeginTag(HtmlTextWriterTag.Td);
            tw.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "white");
            tw.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, "gray");
            tw.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");
            tw.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "1px");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Left, "-4px");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Top, "-4px");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Width, this.mv.Width.ToString());
            tw.AddAttribute(HtmlTextWriterAttribute.Id, "FADatePickerCalendarContainer_" + this.ClientID);
            tw.AddAttribute("CellPadding", "0");
            tw.AddAttribute("CellSpacing", "0");
            tw.RenderBeginTag(HtmlTextWriterTag.Table);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            tw.RenderBeginTag(HtmlTextWriterTag.Td);

            Table table = theme.CreateTitleTable(this.Page);

            table.Width = Unit.Percentage(100.0);
            table.MergeStyle(this.MonthViewTitleStyle);
            table.ID = "FADatePickerCalendarTitle_" + this.ClientID;
            table.RenderBeginTag(tw);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            TableCell cell = new TableCell();

            cell.Style.Add(HtmlTextWriterStyle.TextAlign, "left");
            cell.MergeStyle(this.MonthViewNextPrevStyle);
            cell.RenderBeginTag(tw);

            if ((this.mv.VisibleDate.Month > this.MinDate.Month) || (this.mv.VisibleDate.Year > this.MinDate.Year))
            {
                try
                {
                    DateTime dt = this.mv.VisibleDate.AddMonths(-1);
                    dt = dt.AddDays((double)-(dt.Day - 1));
                    if (this.NextPrevFormat == NextPrevFormat.ShortMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + dt.ToString("MMM") + "</div>");
                    }
                    else if (this.NextPrevFormat == NextPrevFormat.FullMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + dt.ToString("MMMM") + "</div>");
                    }
                    else
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + this.PrevMonthText + "</div>");
                    }
                }
                catch
                {
                }
            }

            cell.RenderEndTag(tw);
            tw.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "center");
            tw.RenderBeginTag(HtmlTextWriterTag.Td);
            tw.WriteLine(this.mv.VisibleDate.ToString("MMMM yyyy"));
            tw.RenderEndTag();
            TableCell cell2 = new TableCell();

            cell2.Style.Add(HtmlTextWriterStyle.TextAlign, "right");
            cell2.MergeStyle(this.MonthViewNextPrevStyle);
            cell2.RenderBeginTag(tw);

            if ((this.mv.VisibleDate.Month < this.MaxDate.Month) || (this.mv.VisibleDate.Year < this.MaxDate.Year))
            {
                try
                {
                    DateTime time9 = this.mv.VisibleDate.AddMonths(1);
                    time9 = time9.AddDays((double)-(time9.Day - 1));
                    if (this.NextPrevFormat == NextPrevFormat.ShortMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + time9.ToString("MMM") + "</div>");
                    }
                    else if (this.NextPrevFormat == NextPrevFormat.FullMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + time9.ToString("MMMM") + "</div>");
                    }
                    else
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + this.NextMonthText + "</div>");
                    }
                }
                catch
                {
                }
            }
            cell2.RenderEndTag(tw);
            tw.RenderEndTag();
            table.RenderEndTag(tw);

            this.mv.RenderControl(tw);

            Table table2 = theme.CreateFooterTable(this.Page);

            table2.ID = string.Format("{0}_Footer", this.ClientID);
            table2.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
            table2.Width = Unit.Percentage(100.0);
            table2.MergeStyle(this.MonthViewFooterStyle);
            table2.RenderBeginTag(tw);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            tw.RenderBeginTag(HtmlTextWriterTag.Td);
            if (this.ShowTodayButton)
            {
                Button button = theme.CreateFooterButton();
                //button.MergeStyle(this.TodayButtonStyle);
                //button.Text = this.TodayButtonText;
                button.OnClientClick = "javascript:SetDate_" + this.ClientID + "('" + DateTime.Today.ToString(this.DateFormat) + "'); return false;";
                button.RenderControl(tw);
            }

            if (this.ShowEmptyButton)
            {
                Button button2 = theme.CreateFooterButton();
                //button2.MergeStyle(this.TodayButtonStyle);
                //button2.Text = this.NoneButtonText;
                button2.OnClientClick = "javascript:SetDate_" + this.ClientID + "(''); return false;";
                button2.RenderControl(tw);
            }
            list.RenderControl(tw);
            //list2.RenderControl(tw);
            tw.RenderEndTag();
            tw.RenderEndTag();
            table2.RenderEndTag(tw);
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();

            return(sb.ToString());
        }