This is a migrated thread and some comments may be shown as answers.

RadScheduler/RadAjaxManager second AJAX request does nothing

4 Answers 177 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 31 Jan 2012, 12:44 AM
We are using RadScheduler and RadAjaxManager and it works for the first AJAX request (eg, change month) but the second request does nothing, no error message, no change to display at all.

This is a little complex to explain but the specifics of the problem are that the website it is used on is a content management system that does not have actual ASPX pages for content pages, instead it uses ASP.NET 4.0 page routing. A routing rule sends the page request to a specific ASPX page which works out the URL requested and displays the requested content.

The problem we are having only occurs on pages requested this way. Our RadScheduler/RadAjaxManager are in an ASCX custom control and if I add that control directly to an ASPX file and request it directly the problem does not happen.

This is the code from our ASCX control:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WsiEventCalendar.ascx.cs" Inherits="STAFF.PageTemplates.WsiEventCalendar" %>
<%@ Register TagPrefix="scheduler" TagName="AdvancedForm" Src="AdvancedForm.ascx" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
  
<asp:Panel ID="pnlError" runat="server" Visible="false">
    Event not found.
</asp:Panel>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
         <asp:ScriptReference Path="AdvancedForm.js" />
            <%--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" >
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
          
        <script type="text/javascript"
        //<![CDATA[
  
            // Dictionary containing the advanced template client object
            // for a given RadScheduler instance (the control ID is used as key).
            var schedulerTemplates = {};
  
            function schedulerFormCreated(scheduler, eventArgs) {
                // Create a client-side object only for the advanced templates
                var mode = eventArgs.get_mode();
                if (mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert ||
                    mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) {
                    // Initialize the client-side object for the advanced form
                    var formElement = eventArgs.get_formElement();
                    var templateKey = scheduler.get_id() + "_" + mode;
                    var advancedTemplate = schedulerTemplates[templateKey];
                    if (!advancedTemplate) {
                        // Initialize the template for this RadScheduler instance
                        // and cache it in the schedulerTemplates dictionary
                        var schedulerElement = scheduler.get_element();
                        var isModal = scheduler.get_advancedFormSettings().modal;
                        advancedTemplate = new window.SchedulerAdvancedTemplate(schedulerElement, formElement, isModal);
                        advancedTemplate.initialize();
  
                        schedulerTemplates[templateKey] = advancedTemplate;
  
                        // Remove the template object from the dictionary on dispose.
                        scheduler.add_disposing(function () {
                            schedulerTemplates[templateKey] = null;
                        });
                    }
  
                    // Are we using Web Service data binding?
                    if (!scheduler.get_webServiceSettings().get_isEmpty()) {
                        // Populate the form with the appointment data
                        var apt = eventArgs.get_appointment();
                        var isInsert = mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert;
                        advancedTemplate.populate(apt, isInsert);
                    }
                }
            }
              
        //]]>
        </script>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function Export(sender, e) {
                $find("<%= RadAjaxManager1.ClientID %>").__doPostBack(sender.name, "");
            }
        </script>
    </telerik:RadCodeBlock>
    <style type="text/css">
        .RadScheduler .rsExportButton
        {
            position: absolute;
            bottom: 0;
            right: 0;
            border: 0;
            height: 24px;
            width: 24px;
            background: url('/images/icons/Outlook.gif') no-repeat center center;
        }
        .RadScheduler .rsAllDayRow .rsExportButton
        {
            right: 20px;
            height: 16px;
            width: 16px;
            background: url('/images/icons/SmallOutlook.gif');
        }
    </style>
<asp:Panel ID="pnlForm" runat="server">
    <telerik:RadScheduler ID="RadScheduler1" runat="server" SelectedView="WeekView"
                TimeZoneOffset="00:00:00" DayStartTime="08:00:00" DayEndTime="18:00:00" OnAppointmentCreated="RadScheduler1_AppointmentCreated" 
                ProviderName="SchedulerData" EnableDescriptionField="True" AppointmentStyleMode="Default" OnAppointmentCommand="RadScheduler1_AppointmentCommand" 
            OnClientFormCreated="schedulerFormCreated" CustomAttributeNames="AppointmentColor,EventLocation">
            <AdvancedForm Modal="true" />
            <Reminders Enabled="false" />
            <AppointmentTemplate>
                <div class="rsAptSubject">
                    <%# Eval("Subject") %>
                </div>
                <%# Eval("Description") %>
                <div style="text-align: right;">
                    <asp:Button runat="server" ID="Button1" CssClass="rsExportButton" ToolTip="Export to iCalendar"
                    CommandName="Export" OnClientClick="Export(this, event); return false;" Style="cursor: pointer;
                    cursor: hand;" />
                </div>
            </AppointmentTemplate>
            <AdvancedEditTemplate>
                <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit" Subject='<%# Bind("Subject") %>'
                    Description='<%# Bind("Description") %>' Start='<%# Bind("Start") %>' End='<%# Bind("End") %>'
                    RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' EventLocation='<%# Bind("EventLocation") %>'
                    AppointmentColor='<%# Bind("AppointmentColor") %>' AudienceID='<%# Bind("Audience") %>'
                    CategoryID='<%# Bind("Category") %>' />
            </AdvancedEditTemplate>
            <AdvancedInsertTemplate>
                <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert" Subject='<%# Bind("Subject") %>'
                    Start='<%# Bind("Start") %>' End='<%# Bind("End") %>' Description='<%# Bind("Description") %>'
                    RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' EventLocation='<%# Bind("EventLocation") %>'
                    AppointmentColor='<%# Bind("AppointmentColor") %>' AudienceID='<%# Bind("Audience") %>'
                    CategoryID='<%# Bind("Category") %>' />
            </AdvancedInsertTemplate>
            <TimelineView UserSelectable="false" />
            <TimeSlotContextMenuSettings EnableDefault="true" />
            <AppointmentContextMenuSettings EnableDefault="true" />
    </telerik:RadScheduler>
</asp:Panel>

And the code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Text;
using SharedDataAccess;
  
namespace STAFF.PageTemplates
{
    public partial class WsiEventCalendar : System.Web.UI.UserControl
    {
  
        protected void Page_Load(object sender, EventArgs e)
        {
  
        }
        protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            e.Appointment.ToolTip = e.Appointment.Subject + ": " + e.Appointment.Description;
  
            //showing the recurring icons
            if (e.Appointment.RecurrenceState == RecurrenceState.Master || e.Appointment.RecurrenceState == RecurrenceState.Occurrence)
            {
                Panel recurrenceStateDiv = new Panel();
                recurrenceStateDiv.CssClass = "rsAptRecurrence";
                e.Container.Controls.AddAt(0, recurrenceStateDiv);
            }
  
            if (e.Appointment.RecurrenceState == RecurrenceState.Exception)
            {
                Panel recurrenceStateDiv = new Panel();
                recurrenceStateDiv.CssClass = "rsAptRecurrenceException";
                e.Container.Controls.AddAt(0, recurrenceStateDiv);
            }
  
        }
  
        protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
        {
            if (e.CommandName == "Export")
            {
                WriteCalendar(RadScheduler.ExportToICalendar(e.Container.Appointment));
            }
        }
  
       
        private void WriteCalendar(string data)
        {
            HttpResponse response = Page.Response;
  
            response.Clear();
            response.Buffer = true;
  
            response.ContentType = "text/calendar";
            response.ContentEncoding = Encoding.UTF8;
            response.Charset = "utf-8";
  
            response.AddHeader("Content-Disposition", "attachment;filename=\"WsiEventExport.ics\"");
  
            response.Write(data);
            response.End();
        }
  
    }
}

Any idea why this problem is happening only in these circumstances?

4 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 02 Feb 2012, 04:08 PM
Hi,

  The described issue has not been reported before. You could try the following options in order to investigate this further:
  • Check if the problem still persists when you replace the RadAjaxManager setup with UpdatedPanel controls in order to isolate if the problem is related with the RadControls
  • Check if there are any client-side errors that are thrown. Tool like FireBug will be appropriate.
  • Make sure the RadAjaxManager is not created after the RadScheduler1 control

Additionally, could you share which content management system you are using?

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
John
Top achievements
Rank 1
answered on 09 Feb 2012, 02:12 AM

•Check if the problem still persists when you replace the RadAjaxManager setup with UpdatedPanel controls in order to isolate if the problem is related with the RadControls

Haven't had a chance to check this yet.

•Check if there are any client-side errors that are thrown. Tool like FireBug will be appropriate.

No client side errors reported.

•Make sure the RadAjaxManager is not created after the RadScheduler1 control

I have checked this.

The content management system is a fully custom-written system. It uses ASP.NET 4.0 page routing to handle content page requests.

0
Antonio Stoilkov
Telerik team
answered on 13 Feb 2012, 05:37 PM
Hi John,

In order to further investigate the issue we will need a live URL showing the unwanted behavior. Additionally, please provide us with a step by step description on how to replicate the issue and report if the replacement of RadAjaxManager with UpdatePanel controls resolves the issue.

Kind regards,
Antonio Stoilkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
John
Top achievements
Rank 1
answered on 27 Mar 2012, 05:25 AM
I was finally getting around to creating a test project that I could attach that would show the problem in action, but whilst doing this I found the cause of the problem.

The problem was that the RadScheduler was in a user control (ascx file) which was being dynamically added to the page at runtime in the Page_Load event.

I changed to the Page_Init event and this solved the problem. There must be something in the Rad products (Scheduler or AJAX, I'm not sure) that needs to run before the Page_Load event on postback.

The problem was nothing to do with routing as I first thought.
Tags
Ajax
Asked by
John
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
John
Top achievements
Rank 1
Share this question
or