RadCalendar IsSelected ignored

4 posts, 0 answers
  1. Jeff Paetkau
    Jeff Paetkau avatar
    35 posts
    Member since:
    Jun 2012

    Posted 16 Jun 2010 Link to this post

    Hi,

    It seems that the RadCalendar.IsSelected property is ignored. The below code should randomly select 1 of every 5 days. Instead none are selected. Any help is appreciated.

    Jeff

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
        <title></title
    </head> 
    <body> 
        <form id="form1" runat="server"
            <asp:ScriptManager runat="server" /> 
            <rad:RadCalendar runat="server" OnDayRender="OnDayRender" EnableMultiSelect="true" /> 
        </form> 
    </body> 
    </html> 
     

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
     
    public partial class _Default : System.Web.UI.Page 
        private Random Rand = new Random(); 
     
        protected void OnDayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
        { 
            if (Rand.Next(5) == 0) 
                e.Day.IsSelected = true
        } 
  2. Martin
    Admin
    Martin avatar
    833 posts

    Posted 22 Jun 2010 Link to this post

    Hello Jeff Paetkau,

    I would suggest that you review the following forum threads:

    Forum1
    Forum2

    I hope this helps,
    Martin
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Jeff Paetkau
    Jeff Paetkau avatar
    35 posts
    Member since:
    Jun 2012

    Posted 22 Jun 2010 Link to this post

    Hi,

    From one of the threads:
    "You might be adding the special day too late in the life cycle of the control"

    Which is what I figured. You just have to use some other logic on Page_Load or something to make it work.

    Might I suggest adding OnDayPreRender or OnDayLoad events. I think they would be very useful.

    Jeff
  4. Martin
    Admin
    Martin avatar
    833 posts

    Posted 23 Jun 2010 Link to this post

    Hello Jeff Paetkau,

    I am afraid that we do not plan to implement similar events in the near future. Based on that I would suggest that you use the following approach:

    Markup:

    <asp:ScriptManager ID="ScriptManager2" runat="server" />
    <telerik:radcalendar runat="server" ID="RadCalendar1"
        enablemultiselect="true" onprerender="RadCalendar1_PreRender" />

    Code-behind:

    private Random Rand = new Random();
    protected void RadCalendar1_PreRender(object sender, EventArgs e)
    {
        for (DateTime date = RadCalendar1.CalendarView.ViewStartDate; date <= RadCalendar1.CalendarView.ViewEndDate; date = date.AddDays(1))
        {
            if (Rand.Next(5) == 0)
            {
                RadCalendar1.SelectedDates.Add(new RadDate(date.Date));
            }
        }
    }

    I hope this helps.

    All the best,
    Martin
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top