OnAjaxRequest Method Master page

3 posts, 0 answers
  1. David
    David avatar
    87 posts
    Member since:
    Jul 2010

    Posted 16 Mar 2011 Link to this post


    I have figured out how to use the client-side ajaxRequestWithTarget method of the RadAjaxManager on a single page. But it all goes a bit pear-shaped when I try to do so on a page that has a Master page.

    I placed a RadAjaxManagerProxy in the Master page. My first question is, which file do I place the event handler RadAjaxManager1_AjaxRequest in? The CodeFile of the Master page (a user control) or the CodeFile of the aspx page?

    I tried it in both places, and the breakpoint which I put in both places was not hit.

    The javascript function which I used to initiate the request was fired by the OnClientSelectedIndexChanged event of a RadComboBox control:
    <telerik:RadCodeBlock ID="RadCodeBlock" runat="server">
        <script type="text/javascript">
            function InitiateAsyncRequestByCombo(sender, eventArgs) {
                var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(this.Page).ClientID %>");
                ajaxManager.ajaxRequestWithTarget("<%= FilterRadComboBox.UniqueID %>", sender.get_selectedItem().get_value());
                return false;

    Is this something which cannot be done when the RadAjaxManager is on a Master page and the other controls are on a ContentPage?
  2. Veli
    Veli avatar
    2002 posts

    Posted 19 Mar 2011 Link to this post

    Hello David,

    Let me note a few points:

    1. The RadAjaxManager.AjaxRequest event does not fire when you use the client-side .ajaxRequestWithTarget() method. The AjaxRequest server event fires when you use the .ajaxRequest() client method. The difference is explained in the following online help topic.  In short, the former method is equivalent  to using __doPostBack(), while the latter is a means of firing AJAX postbacks explicitly through RadAjaxManager.

    2. In a master page / content page scenarios, the RadAjaxManager instance should go in the master page. The content page should have a RadAjaxManagerProxy defined. This is explained in this online help topic.

    3. The AjaxRequest event handler should be attached in whatever page you need the event handler to execute. If this is the master page where you have the RadAjaxManager instance on the page, you use:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"

    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)


    If you need to attach the AjaxRequest handler in the content page, however, the RadAjaxManager instance is not directly available in the content page. In this case, you attach the event handler from code-behind as follows:

    protected void Page_Load(object sender, EventArgs e)
        RadAjaxManager.GetCurrent(Page).AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest);
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)

    the Telerik team
  3. David
    David avatar
    87 posts
    Member since:
    Jul 2010

    Posted 21 Mar 2011 Link to this post

    Thanks Veli,

    Your post did clear that up for me. I was also using the UniqueId when I should have been using the ClientId.
    Having the RadAjaxManager in the Master page does make things get a bit messy, as I need to write code like this:

    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        int selectedValue = int.Parse(e.Argument);           
        ContentPlaceHolder mpContentPlaceHolder;
        RadComboBox filterRadComboBox;
        mpContentPlaceHolder = (ContentPlaceHolder)this.FindControl("DefaultContent");
        filterRadComboBox = mpContentPlaceHolder.FindControl("FilterRadComboBox") as RadComboBox;
        if (this.NamingContainer is AdvWksWCSF.Products.Views.IDefaultView)
            AdvWksWCSF.Products.Views.IDefaultView page = this.NamingContainer as AdvWksWCSF.Products.Views.IDefaultView;

    In that case, a RadComboBox on the Content page called the javascript which fired the Ajax request (ajaxRequest). I'm not sure if there is a more elegant way of doing it. But the above approach does work.

Back to Top