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

RadAjaxManager doesn't execute second request

5 Answers 107 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
roel
Top achievements
Rank 1
roel asked on 02 Feb 2012, 12:01 PM

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();
    }
}

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Feb 2012, 02:32 PM
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
0
roel
Top achievements
Rank 1
answered on 02 Feb 2012, 02:57 PM

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!!

0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Feb 2012, 05:53 PM
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
0
roel
Top achievements
Rank 1
answered on 03 Feb 2012, 08:49 AM

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

0
Maria Ilieva
Telerik team
answered on 07 Feb 2012, 02:18 PM
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 >>
Tags
Ajax
Asked by
roel
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
roel
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or