Пример #1
0
        void DayRenderHandler(Object source, DayRenderEventArgs e)
        {
            SharedBasePage requestPage = this.Page as SharedBasePage;

            e.Day.IsSelectable = false;

            foreach (DateTime day in daysWithEntries)
            {
                if (e.Day.Date == day)
                {
                    e.Cell.Controls.Clear();
                    HyperLink link = new HyperLink();
                    link.Text        = e.Day.DayNumberText;
                    link.NavigateUrl = SiteUtilities.GetDayViewUrl(requestPage.SiteConfig, e.Day.Date);
                    e.Cell.Controls.Add(link);
                    e.Day.IsSelectable = true;
                    break;
                }
            }

            // Because we are using the CssClass property, we explicitely want to check
            // whether a day is both weekend _and_ lastmonth.
            // Otherwise this day would show up either
            // with 'hCalendarOtherMonthStyle' or with 'hCalendarWeekendStyle'.
            if ((e.Day.IsWeekend) && (e.Day.IsOtherMonth))
            {
                e.Cell.CssClass = "hCalendarOtherMonthWeekendStyle";
            }
        }
Пример #2
0
        private void calendarMonth_SelectionChanged(object sender, EventArgs e)
        {
            //If we post back because of a Select Day click then redirect to the Day view with that day.
            // TODO: It'd be cleaner to override the Day rendering and make the link direct
            // and avoid this silly postback.
            SharedBasePage requestPage = this.Page as SharedBasePage;

            Response.Redirect(SiteUtilities.GetDayViewUrl(requestPage.SiteConfig, calendarMonth.SelectedDate));
        }
Пример #3
0
 public static string GetDayViewUrl(SiteConfig siteConfig, DateTime day)
 {
     return(SiteUtilities.GetDayViewUrl(siteConfig, day));
 }
Пример #4
0
 public static string GetDayViewUrl(DateTime day)
 {
     return(SiteUtilities.GetDayViewUrl(day));
 }
Пример #5
0
        private void calendarMonth_DayRender(object sender, DayRenderEventArgs e)
        {
            SharedBasePage    requestPage = this.Page as SharedBasePage;
            MonthViewCalendar eventSource = sender as MonthViewCalendar;

            // This is a standard text label with just the day.  This may get tossed later when
            // we add a HyperLink for those days that have entries.  Otherwise, this serves to
            // override the default LinkButton/PostBack behavior.
            e.Cell.Controls.Clear();
            Literal day = new Literal();

            day.Text = e.Day.DayNumberText;
            e.Cell.Controls.Add(day);

            //For every entry this month, see if we have to render it in this day.
            // I'm sure there are cleaner and faster ways to get this, but I'm using OutputCaching
            // in the ASCX page, so I don't feel so bad.  It's inefficient, but it's largely cached.
            bool controlsCleared = false;

            foreach (Entry entry in eventSource.EntriesThisMonth)
            {
                if (e.Day.Date == entry.CreatedLocalTime.Date)
                {
                    if (controlsCleared == false)
                    {
                        controlsCleared = true;
                        //Override the default LinkButton and PostBack stuff and
                        // replace with a simpler HyperLink Control.
                        e.Cell.Controls.Clear();
                        HyperLink dayLink = new HyperLink();
                        dayLink.Text        = e.Day.DayNumberText;
                        dayLink.NavigateUrl = SiteUtilities.GetDayViewUrl(requestPage.SiteConfig, e.Day.Date);
                        e.Cell.Controls.Add(dayLink);
                    }
                    e.Day.IsSelectable = false;
                    Literal lit = new Literal();
                    lit.Text = "<br />";
                    e.Cell.Controls.Add(lit);

                    HyperLink link = new HyperLink();
                    link.Text        = (entry.Title != null ? entry.Title : TruncateDotDotDot(entry.Content));
                    link.NavigateUrl = SiteUtilities.GetPermaLinkUrl(requestPage.SiteConfig, (ITitledEntry)entry);
                    e.Cell.Controls.Add(link);
                    e.Day.IsSelectable = true;

                    //Poorman's spacer
                    Literal lit2 = new Literal();
                    lit2.Text = "<br />-<br />";
                    e.Cell.Controls.Add(lit2);
                }
            }

            // Because we are using the CssClass property, we explicitely want to check
            // whether a day is both weekend _and_ lastmonth.
            // Otherwise this day would show up either
            // with 'hCalendarOtherMonthStyle' or with 'hCalendarWeekendStyle'.
            if ((e.Day.IsWeekend) && (e.Day.IsOtherMonth))
            {
                e.Cell.CssClass = "lCalendarOtherMonthWeekendStyle";
            }
        }