コード例 #1
0
        protected void Calendar_OnDayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            try
            {
                // modify the cell rendered content for the days we want to be disabled (e.g. every Saturday and Sunday)
                if (e.Day.Date.DayOfWeek != DayOfWeek.Saturday) //|| e.Day.Date.DayOfWeek == DayOfWeek.Sunday)
                {
                    // if you are using the skin bundled as a webresource("Default"), the Skin property returns empty string
                    string calendarSkin       = dpWeekEnding.Calendar.Skin != "" ? dpWeekEnding.Calendar.Skin : "Default";
                    string otherMonthCssClass = "rcOutOfRange";

                    // clear the default cell content (anchor tag) as we need to disable the hover effect for this cell
                    e.Cell.Text     = "";
                    e.Cell.CssClass = otherMonthCssClass; //set new CssClass for the disabled calendar day cells (e.g. look like other month days here)

                    // render a span element with the processed calendar day number instead of the removed anchor -- necessary for the calendar skinning mechanism
                    Label label = new Label();
                    label.Text = e.Day.Date.Day.ToString();
                    e.Cell.Controls.Add(label);

                    // disable the selection for the specific day
                    RadCalendarDay calendarDay = new RadCalendarDay();
                    calendarDay.Date               = e.Day.Date;
                    calendarDay.IsSelectable       = false;
                    calendarDay.ItemStyle.CssClass = otherMonthCssClass;
                    dpWeekEnding.Calendar.SpecialDays.Add(calendarDay);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, typeof(string), "validation", "alert('" + ex.Message + "')", true);
            }
        }
コード例 #2
0
        protected void CustomizeDay2(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            DateTime CurrentDate = e.Day.Date;
            string   endDate     = string.IsNullOrEmpty((string)ViewState["fecFinal"]) ? "1" : (string)ViewState["fecFinal"];

            //if (startDate <= CurrentDate && CurrentDate <= endDate)
            //{
            if (CurrentDate.Day == Convert.ToInt32(endDate))
            {
                TableCell currentCell = e.Cell;
                currentCell.Style["background-color"] = "Green";
                currentCell.Text = endDate;
            }
            //}
        }
コード例 #3
0
        /// <summary>
        /// Handles the DayRender event of the Cal control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.Calendar.DayRenderEventArgs"/> instance containing the event data.</param>
        protected void Cal_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            // skip other month days
            if (e.Day.Date.Month != this.selectedDate.Month)
            {
                return;
            }

            // no events?
            if (this.Month_Events == null || this.Month_Events[e.Day.Date.Day].Count() == 0)
            {
                return;
            }

            // build links to events
            var sb = new StringBuilder();

            sb.Append("<ul>");

            // parse events
            foreach (var ev in this.Month_Events[e.Day.Date.Day])
            {
                // details page set?
                if (string.IsNullOrEmpty(this.DetailsPage))
                {
                    sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", ev.Urls[0].Url, ev.Title);                     // use current page
                }
                else
                {
                    sb.AppendFormat("<li><a href=\"{0}{1}\">{2}</a></li>", this.ResolveUrl(this.DetailsPage), ev.Urls[0].Url, ev.Title); // use details page
                }
            }

            sb.Append("</ul>");

            // write html
            e.Cell.Text += sb.ToString();
        }
コード例 #4
0
 protected void RadCalendar_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
 {
 }