RadAjaxManager doesn't execute second request

6 posts, 0 answers
  1. roel
    roel avatar
    3 posts
    Member since:
    Jun 2011

    Posted 02 Feb 2012 Link to this post

    I have a simple test project. 

    One panel executes a timer every 4 seconds (a long running task).

    Another panel has a button that will redirect to another page.

    Each panel is added to the radajaxmanager ajaxsettings

    When the timer is executing, the button on the second panel never executes (although the loading panel is shown). So the new page isn't shown.

    This is the code I use:

    protected void Page_Load(object sender, EventArgs e)
        {
            RadAjaxManager1.RequestQueueSize = 3;
              
            // Panel 1
            Panel panel = new Panel();
            panel.Height = 200;
            panel.Width = 200;
            panel.BorderColor = System.Drawing.Color.Green;
            panel.BorderWidth = 3;
            panel.BorderStyle = BorderStyle.Solid;
            panel.ID = "NewPanel";
            Label newLabel = new Label();
            newLabel.ID = "NewLabel";
            panel.Controls.Add(newLabel);
            Timer newTimer = new Timer();
            newTimer.ID = "newTimer";        
            newTimer.Interval = 4000;
            newTimer.Enabled = true;         
            newTimer.Tick += newTimer_Tick;
            panel.Controls.Add(newTimer);
      
            RadButton newButton = new RadButton();
            newButton.ID = "newButton";
            newButton.Click += newButton_Click;
            panel.Controls.Add(newButton);
                      
            form1.Controls.Add(panel);
      
            // Panel 2
            Panel panel2 = new Panel();
            panel2.Height = 200;
            panel2.Width = 200;
            panel2.BorderColor = System.Drawing.Color.Beige;
            panel2.BorderWidth = 3;
            panel2.BorderStyle = BorderStyle.Solid;
            panel2.ID = "NewPanel2";
            Label newLabel2 = new Label();
            newLabel2.ID = "NewLabel2";
            panel2.Controls.Add(newLabel2);
      
            RadButton newButton2 = new RadButton();
            newButton2.ID = "newButton2";
            newButton2.Click += newButton2_Click;
            panel2.Controls.Add(newButton2);
      
            form1.Controls.Add(panel2);
      
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel, panel);
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel2, panel2);
        }
      
        void newButton2_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(500);        
            this.Page.Response.Redirect("~/Test.aspx");
        }
      
        void newButton_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(500);
            Label lbl = Page.FindControl("NewLabel") as Label;
            lbl.Text = System.DateTime.Now.ToString();
        }
        void newTimer_Tick(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(3000);
            Label lbl = Page.FindControl("NewLabel") as Label;
            lbl.Text = System.DateTime.Now.ToString();
        }
    }

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 02 Feb 2012 Link to this post

    Hello,

    protected void Page_Load(object sender, EventArgs e)
    {
        RadAjaxManager1.RequestQueueSize = 3;
           
        // Panel 1
        Panel panel = new Panel();
        panel.Height = 200;
        panel.Width = 200;
        panel.BorderColor = System.Drawing.Color.Green;
        panel.BorderWidth = 3;
        panel.BorderStyle = BorderStyle.Solid;
        panel.ID = "NewPanel";
        Label newLabel = new Label();
        newLabel.ID = "NewLabel";
        panel.Controls.Add(newLabel);
        Timer newTimer = new Timer();
        newTimer.ID = "newTimer";       
        newTimer.Interval = 4000;
        newTimer.Enabled = true;        
        newTimer.Tick += newTimer_Tick;
        panel.Controls.Add(newTimer);
     
        RadButton newButton = new RadButton();
        newButton.ID = "newButton";
        newButton.Click += newButton_Click;
        panel.Controls.Add(newButton);
                   
        form1.Controls.Add(panel);
     
        // Panel 2
        Panel panel2 = new Panel();
        panel2.Height = 200;
        panel2.Width = 200;
        panel2.BorderColor = System.Drawing.Color.Beige;
        panel2.BorderWidth = 3;
        panel2.BorderStyle = BorderStyle.Solid;
        panel2.ID = "NewPanel2";
        Label newLabel2 = new Label();
        newLabel2.ID = "NewLabel2";
        panel2.Controls.Add(newLabel2);
     
        RadButton newButton2 = new RadButton();
        newButton2.ID = "newButton2";
        newButton2.Click += newButton2_Click;
        panel2.Controls.Add(newButton2);
     
        form1.Controls.Add(panel2);
     
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel, panel);
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel2, panel2);
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel, panel2, RadAjaxLoadingPanel1);
    }
     
    void newButton2_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(500);       
        this.Page.Response.Redirect("~/Test.aspx");
    }
     
    void newButton_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(500);
        Label lbl = Page.FindControl("NewLabel") as Label;
        lbl.Text = System.DateTime.Now.ToString();
    }
    void newTimer_Tick(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        Label lbl = Page.FindControl("NewLabel") as Label;
        lbl.Text = System.DateTime.Now.ToString();
    }
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
          </telerik:RadScriptManager>
          <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
          </telerik:RadAjaxManager>
          <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>


    Thanks,
    Jayesh Goyani
  3. roel
    roel avatar
    3 posts
    Member since:
    Jun 2011

    Posted 02 Feb 2012 Link to this post

    Hi Jayesh,

    thanks for the update but that's not the behavior I want.

    With your change

    RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel, panel);
    RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel2, panel2);
    RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel, panel2, RadAjaxLoadingPanel1);

    I can't click my button when the timer is executing and that's what I want.

    To click the button during the refresh. 

    I tried with setting the queue to 0 so that the timer action is cancelated when clicking the button, but then the loading panel (of the button) isn't shown anymore and that's really a requirement...

    Any suggestions are welcome!!

  4. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 02 Feb 2012 Link to this post

    Hello,

    Then, its better to do this thing by JS.

    http://forums.asp.net/t/1315777.aspx/1

    Let me know if you have any concern.

    Thanks,
    Jayesh Goyani
  5. roel
    roel avatar
    3 posts
    Member since:
    Jun 2011

    Posted 03 Feb 2012 Link to this post

    Hi,

    thanks but that's not what I needed. In this small example I do a redirect but in my real world project, a lot of other things needs to be done server side before a redirect is done...

     best regards,

    Roel

  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Feb 2012 Link to this post

    Hello Roel,

    If you need to terminate the firstly started Ajax request in order to perform another one you should set the QueueSize to 0 as you already mentioned. Note that when the firstly request is terminated it could not continue after that.
    As for the LoadingPanel you could try showing and hidden the LoadingPanel explicitly as shown here.

    I hope this helps.


    Greetings,
    Maria Ilieva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top