Ajaxify the control from code behind

2 posts, 0 answers
  1. nav100
    nav100 avatar
    48 posts
    Member since:
    Dec 2010

    Posted 18 Apr 2012 Link to this post

    I am trying to Ajaxify RadGrid control and label in code behind. Here is my code. But it doesn't work. Could you please let me know what could be the problem. I am trying to refresh the Label control when RadGrid changed.

    Thank you for any help.

                            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                                <AjaxSettings>
                                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                                        <UpdatedControls>
                                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                                        </UpdatedControls>
                                    </telerik:AjaxSetting>
                                </AjaxSettings>
                            </telerik:RadAjaxManager>
      
                            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
                                <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false">
                                    <MasterTableView>
                                        <Columns>
                                        </Columns>
                                    </MasterTableView>
                                </telerik:RadGrid>
                            </telerik:RadAjaxPanel>
                <div id="div1" runat="server">
                    <table id="table1" runat="server" >
                        <tr>
                            <td align="center">
                                <asp:Label ID="lblName" runat="server" Font-Bold="true"> </asp:Label>
                            </td>
                        </tr>
                    </table>
                </div>
      
    Code behind.
      
            protected void Page_Load(object sender, EventArgs e)
            {
                try
                {
                    if (!Page.IsPostBack)
                    {
                       RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, lblName, null);
                    }
                }
            }
  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 19 Apr 2012 Link to this post

    Hi,

    Note that you should not use RadAjaxManager and RadAjaxPanel at the same time. Try changing your code as shown below and let us know how it goes.
                          <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                            </telerik:RadAjaxManager>
     
                                <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false">
     
                                    <MasterTableView>
     
                                        <Columns>
     
                                        </Columns>
     
                                    </MasterTableView>
     
                                </telerik:RadGrid>
     
                <div id="div1" runat="server">
     
                    <table id="table1" runat="server" >
     
                        <tr>
     
                            <td align="center">
     
                                <asp:Label ID="lblName" runat="server" Font-Bold="true"> </asp:Label>
     
                            </td>
     
                        </tr>
     
                    </table>
     
                </div>
     
    Code behind
            protected void Page_Load(object sender, EventArgs e)
            {
                try
                {
                    if (!Page.IsPostBack)
                    {
                       RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, lblName, null);
                    }
                }
            }

    Greetings,
    Pavlina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top