cancel AjaxRequest on server side

7 posts, 0 answers
  1. Marco
    Marco avatar
    37 posts
    Member since:
    Jul 2007

    Posted 08 May 2008 Link to this post

    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

  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 10 May 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. lampy
    lampy avatar
    47 posts
    Member since:
    Oct 2006

    Posted 10 May 2008 Link to this post

    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.
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 May 2008 Link to this post

    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
  6. lampy
    lampy avatar
    47 posts
    Member since:
    Oct 2006

    Posted 10 May 2008 Link to this post

    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
  7. Marco
    Marco avatar
    37 posts
    Member since:
    Jul 2007

    Posted 10 May 2008 Link to this post

    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

  8. Marco
    Marco avatar
    37 posts
    Member since:
    Jul 2007

    Posted 19 May 2008 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017