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

Multiple AjaxRequest Events

1 Answer 150 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
CharlesM
Top achievements
Rank 1
CharlesM asked on 11 Apr 2009, 05:39 AM
I have a website that is structured as follows:

-> MasterPage  - Contains RadAjaxManager control
     ->Page
          ->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?   

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 14 Apr 2009, 06:34 AM
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:

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

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,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
CharlesM
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or