Multiple AjaxRequest Events

2 posts, 0 answers
  1. CharlesM
    CharlesM avatar
    14 posts
    Member since:
    Jun 2007

    Posted 11 Apr 2009 Link to this post

    I have a website that is structured as follows:

    -> MasterPage  - Contains RadAjaxManager control
              ->Control 1 
              ->Control 2
              ->Control 3
              ->Control 4

    Each control needs to implement a AjaxRequest event handlers for control specific events (nothing cross control, or master page stuff). So in each control I am using RadAjaxManager.GetCurrent(this.Page) method and attach to the AjaxRequest event. The problem I am having is that if the javascript from Control 1 fires the AjaxRequest event all of the other controls seem to get their event handlers called as well. Is there a way to filter the requests so they don't all fire? Is there a better way to do this?   
  2. Pavlina
    Pavlina avatar
    6165 posts

    Posted 14 Apr 2009 Link to this post

    Hello Charles,

    You can get the "master" manager instance via Server-Side GetCurrent method from the ContentPage code-behind: RadAjaxManager.GetCurrent(Page)

    I suggest that you use server-side code block in your JS function to call the master manager AjaxRequest function from the ContentPage as well:

     <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
           <script type="text/javascript">  
               function myContentClickHandler()  
                   $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("<my_control_id>");  

    Hence if your AjaxRequest handler resides in one place, namely the master page code-behind, and you determine there which of the page control raised the event (passing the control id as an arguments of the ajaxRequest client method for example), your code logic can be executed uniquely based on the respective control id value available in the OnAjaxRequest server handler through e.Argument.

    Find more information about your scenario in the following articles:
    RadAjax and MasterPage
    MasterPages: ajaxify and update controls in master and content page
    MasterPages: initiating requests from one ContentPlaceHolder and loading/updating controls in another

    Kind regards,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top