Attach more than one function to RadAjaxManager's OnRequestStart or OnRequestEnd

4 posts, 0 answers
  1. Andrew Lawrence
    Andrew Lawrence avatar
    32 posts
    Member since:
    Mar 2007

    Posted 30 Nov 2010 Link to this post

    Is there a clean, modular way to do this?

    For example, the following code is dangerous because it may erase any existing function that is attached to OnRequestStart:

    RadAjaxManager.GetCurrent(Page).ClientEvents.OnRequestStart = "DoSomething";
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 02 Dec 2010 Link to this post

    Hello Andrew,

    Could you please elaborate a bit more on your scenario and the exact functionality you need to achieve. Pasting some code from your application which represents the Ajax settings you have, could help us provide more to-the-point answer.


    Best wishes,
    Maria Ilieva
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Andrew Lawrence
    Andrew Lawrence avatar
    32 posts
    Member since:
    Mar 2007

    Posted 02 Dec 2010 Link to this post

    I have a script that needs to fire OnResponseEnd that is designed to retain focus on the active element after an AJAX postback.
    This script is registered in a global manner, e.g. in a master page:

    public class MasterPageBase : MasterPage
    {
            protected override void OnLoad(EventArgs e)
            {
                radAjaxManager.ClientEvents.ResponseEnd = "TrackFocusAfterAjaxPostback";
                base.OnLoad(e);
            }
    }


    But now I have a requirement that applies to a particular content page. After an AJAX postback, I need to make sure that any controls that have become visible are processed by some javascript. For example:

    <script type="text/javascript">
        function AttachEventsToTextboxes() {
            $(':text').change(function () { DoSomething(); });
        }
     
        // Attach events on load
        AttachEventsToTextboxes()
    </script>


    ... and In the code behind:

    public partial class MyContentPage : Page
    {
            protected override void OnLoad(EventArgs e)
            {
                RadAjaxManager.GetCurrent(Page).ClientEvents.ResponseEnd = "AttachEventsToTextboxes";
                base.OnLoad(e);
            }
    }



    The problem is that the subpage's ResponseEnd script will overwrite the Master Page's ResponseEnd script.
    This may not be obvious to the developer, resulting in subtle bugs.
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Dec 2010 Link to this post

    Hi Andrew,

    The ResponseEnd is a client event so you cannot call two functions in the same time. In your case I would suggest you to please the code used in the MasterPage function in the content page function so it will be executed in the same time.


    Greetings,
    Maria Ilieva
    the Telerik team

    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top