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

cancel AjaxRequest on server side

6 Answers 230 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 08 May 2008, 11:52 PM
Hello,

I try to figure this out, but didn't find a solution for this.
I have a timer in my application, that do a regular check for updated data in the database.
If the data is updated there are four radgrids that need to be updated.
This timer is ajaxfied with the RadAjaxManager, and has the four radgrids as UpdatedControls.
This works ok, but i want a final touch to have it perfect.

Now, when the data is not updated, the radgrids dont't load data, but are still refreshing on the page, and the loading label is shows also.
What i want, is that when there is no data updated, the ajaxrequest is canceled, and nothing happens with the radgrids.
But i can't find a way to cancel the ajaxrequest in the server side timer event.

Or is there another way to do this?.

Thanks

6 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 10 May 2008, 07:57 AM
Hi Marco,

Can you clarify whether you are using the Classic RadAjax or RadAjax for ASP.NET AJAX? If the Classic one, you can pass an argument depending on whether there is new data or not and cancel the ajax request if there is no data (help article here). Another option would be using the ResolveUpdatedControls eventhandler and clear the updated controls collection on your condition.
If you are using RadAjax for ASP.NET AJAX, you can hook up to AjaxSettingCreating and cancel the creation of the updatePanels for the grids based on your condition.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
lampy
Top achievements
Rank 1
answered on 10 May 2008, 02:49 PM
If you are using ASP.NET AJAX, you could create a web service or page method that checks to see if new data exists.  That method would return a bool and if true then fire a Telerik AJAX request via javascript and update your grids. If false do nothing.  A web service or page method via ASP.NET AJAX is a lot more performant than a Telerik AJAX request (no postback).  That is my 2 cents.
0
Vlad
Telerik team
answered on 10 May 2008, 04:20 PM
Hello lampy,

Actually Telerik AJAX request is exactly the same as UpdatePanel AJAX request :)

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
lampy
Top achievements
Rank 1
answered on 10 May 2008, 04:30 PM
Vlad,

You misunderstood my post.  I told Marco to create a webservice or page method to check to see if the data has changed.  If it has changed fire a Telerik AJAX request to update the grids via an AJAX manager and AJAX panel.  This way he does not have to cancel the AJAX request via the server side and the webservice/page method is a lightweight AJAX request.

Thanks,

Darin
0
Marco
Top achievements
Rank 1
answered on 11 May 2008, 02:29 AM
Both thanks for the reply's.

I use the RadAjax for Asp.Net Ajax.
I think the webservice or page method won't work, because this part of the application where the datagrids resize, (including a changing graphical map) is purely a (big) information screen. So i must use a timer, because it must regular check and update the data, without user interference.

When i hook up the AjaxSettingCreating, the check for updated data must be done for every control that needs to be updated. (not realy what i want )
Beside that, the page is doing a full refresh if the Ajaxrequest is canceled.
(That figures because only the AjaxRequest is canceled, not the postback from the timer)

Marco

0
Marco
Top achievements
Rank 1
answered on 20 May 2008, 01:24 AM
To wrap this up, this is how i have finaly get the wanted behauvior.
Just a simple way, but this gives me exactly what i wanted.
(no refresh and loading panels, when no data is updated)

I use now 2 timers, and put them in a updatepanel..
I have still all the grids set to updated controls for timer1, but this timer1 is now disabled.
Timer2 is doing a frequently check for  updated data, and if the data is updated, timer1 is enabled by timer2.
Timer1 is doing a databind and refresh of all the datagrids, and disables himself after this.

It is just for the final touch, to have not to many refreshes.

 
Tags
Ajax
Asked by
Marco
Top achievements
Rank 1
Answers by
Steve
Telerik team
lampy
Top achievements
Rank 1
Vlad
Telerik team
Marco
Top achievements
Rank 1
Share this question
or