Subscribe OnResponseEnd/OnRequestStart on client-side

5 posts, 0 answers
  1. Andrey
    Andrey avatar
    7 posts
    Member since:
    May 2011

    Posted 22 Dec 2011 Link to this post

    Although there is really very good client-side support in Telerik controls, I can't find the way to subscribe AjaxManager OnResponseEnd/OnRequestStart events on client-side. The only way that I see is to do this on server-side (via codebehind or via declaration).
    Could you please clarify if there is any way to subscribe to these events on client-side?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Dec 2011 Link to this post

    Hello Andrey,

    You can attach client events as explained in this documentation. Also check the online demo which implements the same.

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrey
    Andrey avatar
    7 posts
    Member since:
    May 2011

    Posted 22 Dec 2011 Link to this post

    Thank you for links, Shinu, but I have read these articles. They explain that you can attach client-side events to ResponseEnd/RequestStart via assigning property on server-side, but I need to do this completely in javascript. Like:
    $find(ajaxManagerId).add_onResponseEnd(func)
    Is there any way to do this?
  5. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 23 Dec 2011 Link to this post

    Hello Andrey,

    You can attach the events using js like so:

    $find(ajaxManagerId).OnResponseEnd = func;

    You'll just need to register it every time an ajax request is performed, as it gets removed.

    I hope that helps.
  6. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 23 Dec 2011 Link to this post

    Hello Andrey,

    You could hook the OnAjaxRequest and OnResponceEnd events of RadAjaxManager just like you will do it with any JavaScript event. Namely:

    function pageLoad(sender, args) {
        var ajaxManager = $find("<%=RadAjaxManager1.ClientID %>");
        ajaxManager.OnRequestStart = "requestStart(this, event)";
    }
    function requestStart(sender, args) {
        alert("Request had started");
    }

    However, with this approach you are loosing the specific information from the OnRequestStart event argument and you are receiving the DOM event argument.

    Another approach is to hook the OnRequestStart event from the server and in its body to check if some condition is met and then to cancel the event. Like this:

    function requestStart(sender, args) {
    if(some condition is met){
    args.set_cancel(true);
    }
    }

    Greetings,
    Andrey
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017