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

RadAjaxManager MasterPages and AjaxRequestDelegate

1 Answer 133 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
jose luis
Top achievements
Rank 1
jose luis asked on 27 Jun 2011, 02:56 AM
Hi,

in an scenario with a master page with the Radajaxmanager control and a content page with a grid i never get the Ajaxrequestdelegate event reach, in this case RadAjaxManager1_AjaxRequest, thanks a lot

the code behind of the content page:

       protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RadAjaxManager AjaxManager = (RadAjaxManager)this.Master.FindControl("RadAjaxManager1");
                //                RadAjaxManager AjaxManager = RadAjaxManager.GetCurrent(Page);
                AjaxManager.AjaxSettings.AddAjaxSetting(AjaxManager, RadGridClientes);
                AjaxManager.AjaxSettings.AddAjaxSetting(RadGridClientes, RadGridClientes);
                AjaxManager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest);
            }

        }

        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            if (e.Argument == "Rebind")
            {
                RadGridClientes.MasterTableView.SortExpressions.Clear();
                RadGridClientes.MasterTableView.GroupByExpressions.Clear();
                RadGridClientes.Rebind();
            }
            else if (e.Argument == "RebindAndNavigate")
            {
                RadGridClientes.MasterTableView.SortExpressions.Clear();
                RadGridClientes.MasterTableView.GroupByExpressions.Clear();
                RadGridClientes.MasterTableView.CurrentPageIndex = RadGridClientes.MasterTableView.PageCount - 1;
                RadGridClientes.Rebind();
            }
        }

in the content page aspx file:


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">



    <telerik:RadGrid ID="RadGridClientes" runat="server">
    </telerik:RadGrid>

                <telerik:RadButton Text="Cancelar" runat="server" ID="Cancelar" OnClientClicked="refreshGrid">
                </telerik:RadButton>

   <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function refreshGrid(arg) {
            if (!arg) {
                $find("<%= RadAjaxManager.GetCurrent(this.Page).ClientID %>").ajaxRequest("Rebind");
            }
            else {
                $find("<%= RadAjaxManager.GetCurrent(this.Page).ClientID %>").ajaxRequest("RebindAndNavigate");
            }
        }
    
    </script>
    </telerik:RadCodeBlock>
</asp:Content>

1 Answer, 1 is accepted

Sort by
0
Accepted
Genti
Telerik team
answered on 28 Jun 2011, 07:23 AM
Hi jose luis,

The conditional statement on page load is adding a handler to the ajax request only when the page is loaded(not on postback). This way the handler would be attached and unloaded when the page unloads, it won't be persisted in further requests.
Therefore I would suggest you remove the conditional statement in the page load.

Let me know if this helps.

Greetings,
Genti
the Telerik team

Browse the vast support resources we have to jump start 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.

Tags
Ajax
Asked by
jose luis
Top achievements
Rank 1
Answers by
Genti
Telerik team
Share this question
or