Shared Calender with RadAjaxManager Fails after Postback

2 posts, 1 answers
  1. TheLostLeaf
    TheLostLeaf avatar
    34 posts
    Member since:
    Feb 2007

    Posted 03 Mar 2011 Link to this post

    Hi,

    I've had this problem for a while and have not found a solution. When using a Shared Calender with the RadAjaxManager, the pop-up only works the 1st time. Here is the simplest implementation of the example.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="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">
    <head runat="server">
        <title></title>
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    </head>
    <body>
        <form id="form1" runat="server">
      
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
        <div id="divContent" runat="server">
            <telerik:RadCalendar ID="RadCalendar1" Runat="server"></telerik:RadCalendar>
        </div>
        </form>
    </body>
    </html>
    using System;
    using System.Drawing;
    using Telerik.Web.UI;
      
    public partial class Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadDatesShared();
        }
      
        void LoadDatesShared()
        {
            for (int i = 0; i < 10;i++ )
            {
                RadDatePicker rdp = new RadDatePicker();
                rdp.SharedCalendar = RadCalendar1;
                rdp.AutoPostBack = true;
                rdp.ID = "rdp" + i.ToString();
                rdp.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(rdp_SelectedDateChanged);
                divContent.Controls.Add(rdp);
                RadAjaxManager1.AjaxSettings.AddAjaxSetting(rdp, rdp);
            }
        }
      
        void rdp_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
        {
            ((RadDatePicker)sender).BackColor = Color.LightGreen;
        }
      
    }

    Thanks !
  2. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    1873 posts

    Posted 09 Mar 2011 Link to this post

    Hello,

    When you are using shared calendars with AJAX you need to make sure that each picker updates itself, all other pickers and the shared calendar. In your case only the first condition is fulfilled. This is because the client states of all pickers should be refreshed when they are sharing a calendar in order for them to be able to find the client object of the control.

    Best wishes,
    Tsvetina
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top