dynamic raddatepickers SharedCalendar not working right

4 posts, 0 answers
  1. Steven
    Steven avatar
    32 posts
    Member since:
    Jul 2012

    Posted 08 Dec 2011 Link to this post

    I am adding raddatepickers to the page dynamically and the sharecalendar part isn't working.

    I have some sample code below. 
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadDatePickerTest.aspx.cs" Inherits="NCCCN.CMIS.AdHOC.RadDatePickerTest" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"  />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" />
        <asp:PlaceHolder runat="server" ID="TemplatePH" />
        <asp:PlaceHolder runat="server" ID="PlaceHolder1" />
     
        <br /><br />
     
     
        <telerik:RadDatePicker runat="server" ID="ACal" />
        <telerik:RadDatePicker runat="server" ID="BCal" />
     
        </div>
        </form>
    </body>
    </html>



    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    RadCalendar cal = new RadCalendar();
    cal.ClientIDMode = System.Web.UI.
    ClientIDMode.Static;
    cal.EnableMultiSelect =
    false;
    cal.ID =
    this.ClientID + "SharedCalID";
    TemplatePH.Controls.Add(cal);
    RadDatePicker StartDatePicker = new RadDatePicker();
    StartDatePicker.ClientIDMode = System.Web.UI.
    ClientIDMode.Static;
    StartDatePicker.AutoPostBack =
    true;
    //StartDatePicker.SelectedDateChanged += new SelectedDateChangedEventHandler(StartDatePicker_SelectedDateChanged);
    StartDatePicker.SharedCalendar = cal;
    StartDatePicker.SelectedDate =
    new DateTime(2005, 1, 1);
    StartDatePicker.ID =
    this.ClientID + "SentFromFilterTemplate_StartDatePicker";
    TemplatePH.Controls.Add(StartDatePicker);
     
    RadDatePicker EndDatePicker = new RadDatePicker();
    EndDatePicker.ClientIDMode = System.Web.UI.
    ClientIDMode.Static;
    EndDatePicker.AutoPostBack =
    true;
    // EndDatePicker.SelectedDateChanged += new SelectedDateChangedEventHandler(EndDatePicker_SelectedDateChanged);
    EndDatePicker.SharedCalendar = cal;
    EndDatePicker.SelectedDate =
    new DateTime(2006, 1, 1);
    EndDatePicker.ID =
    this.ClientID + "SentFromFilterTemplate_EndDatePicker";
    TemplatePH.Controls.Add(EndDatePicker);
    ACal.SharedCalendar = cal;
    BCal.SharedCalendar = cal;
    }
    }

     

     

     

     

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Dec 2011 Link to this post

    Hello,

    Try the following code snippet.
    CS:
    protected void Page_Load(object sender, EventArgs e)
       {
           RadCalendar RadCalendar1 = new RadCalendar();
           RadCalendar1.ID = "radcal";
           RadCalendar1.EnableMultiSelect = false;
           RadCalendar1.Skin = "Sunset";
           RadCalendar1.EnableMonthYearFastNavigation = false;
           RadCalendar1.UseColumnHeadersAsSelectors = false;
           RadCalendar1.UseRowHeadersAsSelectors = false;
           PlaceHolder1.Controls.Add(RadCalendar1);
           RadDatePicker1.SharedCalendarID = "radcal";
           RadDatePicker2.SharedCalendarID = "radcal";
      }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steven
    Steven avatar
    32 posts
    Member since:
    Jul 2012

    Posted 09 Dec 2011 Link to this post

    thanks, but its still not working if RadDatePicker1 and RadDatePicker2 are added to the page dynamically like the RadCalendar  is
  5. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 09 Dec 2011 Link to this post

    Hello Steven,

    I tried using your code in .NET 3.5 and it worked (I had to remove the Static ID part). Perhaps the issue is related to you setting the ClientIDMode as Static. What happens if you remove that part from your controls?

    Also, if you set these lines on your RadCalendar:

    cal.ShowOtherMonthsDays = false;
    cal.ShowRowHeaders = false;

    It should make it more apparent when you're testing it, if they are really sharing the calendar.

    I hope that helps.
Back to Top