RadAjaxManager doesn't work with my radcombobox

4 posts, 0 answers
  1. Arnoldo
    Arnoldo avatar
    2 posts
    Member since:
    Nov 2013

    Posted 27 Nov 2013 Link to this post

    Hi telerik, 
    I have a problem using the RadAjaxManager Control, I'm trying to load a combobox depending on the selected item in another combobox in a webform, but for do that the autopostback of the combobox has to be in true mode, so i add a RadAjaxManager so I would not reload the whole page, but it doesn't work.

    I want to load the combobox cmbCuenta depending on the selected item in cmbBanco without reload the whole page. Thanks, for your help.

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
            <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="cmbBanco">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="cmbCuenta" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="cmbCuenta">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="cmbChequera" />
                            <telerik:AjaxUpdatedControl ControlID="cmbMoneda" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="cmbTipoCuentaC">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="cmbCuentaContable" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager> 

     <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Office2010Silver">
                <div class="loading">
                <asp:Image ID="Image1" runat="server" ImageUrl="~/Imagenes/loading1.gif" AlternateText="loading"></asp:Image>
                </div>
            </telerik:RadAjaxLoadingPanel>  


    <table align="center" style="width: 98%">
                    <tr>
                        <td class="auto-style4">
                            Banco:
                        </td>
                        <td colspan="2" class="auto-style4">
                            <telerik:RadComboBox ID="cmbBanco" runat="server" AutoPostBack="true" DataSourceID="SqlDataBanco" DataTextField="Nombre" DataValueField="IdBanco" EmptyMessage="Seleccione un Banco" OnSelectedIndexChanged="cmbBanco_SelectedIndexChanged">
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top; width: 20%" align="left" class="auto-style5">
                            <asp:Label ID="lblCuenta" runat="server" Text="Cuenta:"></asp:Label>
                        </td>
                        <td style="vertical-align: top; width: 30%" align="left">
                            <telerik:RadComboBox ID="cmbCuenta" Runat="server" Width="211px" AutoPostBack="true" OnSelectedIndexChanged="cmbCuenta_SelectedIndexChanged" EmptyMessage="Seleccione una Cuenta Bancaria">
                            </telerik:RadComboBox>
                        </td>
                        <td style="vertical-align: top; width: 20%" align="left" class="auto-style3">
                            <asp:Label ID="lblFecha" runat="server" Text="Fecha de emisión:"></asp:Label>
                        </td>
                        <td style="vertical-align: top; width: 30%" align="left" class="auto-style4">
                            <telerik:RadDatePicker ID="dttFechaEmision" runat="server">                            
                            </telerik:RadDatePicker>
                        </td>
                    </tr>
                </table>
    </asp:Content>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Nov 2013 Link to this post

    Hi Arnoldo,

    The scenario like WebUserControls or Master/ContentPages try to set the RadAjaxManager instance on the main/master page and add a proxy to the usercontrol/content page. RadAjaxManagerProxy copies the exact same RadAjaxManager designer configuration so that you can set all the necessary AJAX settings within the WebUserControl/ContentPage entirely through the designer.  Please have a look into the following code snippet which works fine at my end.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
    </telerik:RadAjaxManager>
           
    UserControlPage :
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="cmbBanco">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="cmbCuenta" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Office2010Silver">
            <div class="loading">
                <asp:Image ID="Image1" runat="server" ImageUrl="~/Imagenes/loading1.gif" AlternateText="loading">
                </asp:Image>
            </div>
        </telerik:RadAjaxLoadingPanel>
        <table align="center" style="width: 98%">
            <tr>
                <td class="auto-style4">
                    Banco:
                </td>
                <td colspan="2" class="auto-style4">
                    <telerik:RadComboBox ID="cmbBanco" runat="server" AutoPostBack="true" DataSourceID="SqlDataSource1"
                        DataTextField="Countryname" DataValueField="Countryname" EmptyMessage="Seleccione un Banco"
                        OnSelectedIndexChanged="cmbBanco_SelectedIndexChanged">
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td style="vertical-align: top; width: 20%" align="left" class="auto-style5">
                    <asp:Label ID="lblCuenta" runat="server" Text="Cuenta:"></asp:Label>
                </td>
                <td style="vertical-align: top; width: 30%" align="left">
                    <telerik:RadComboBox ID="cmbCuenta" runat="server" Width="211px" AutoPostBack="true"
                        EmptyMessage="Seleccione una Cuenta Bancaria">
                    </telerik:RadComboBox>
                </td>
                <td style="vertical-align: top; width: 20%" align="left" class="auto-style3">
                    <asp:Label ID="lblFecha" runat="server" Text="Fecha de emisión:"></asp:Label>
                </td>
                <td style="vertical-align: top; width: 30%" align="left" class="auto-style4">
                    <telerik:RadDatePicker ID="dttFechaEmision" runat="server">
                    </telerik:RadDatePicker>
                </td>
            </tr>
        </table>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT  [Countryname],  [Cityname] FROM [City]"></asp:SqlDataSource>
    </asp:Content>

    UserControlPage C#:
    protected void cmbBanco_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        DataTable data = GetData(new SqlCommand("SELECT Cityname FROM City WHERE Countryname = '" + cmbBanco.SelectedItem.Text + "'"));
        cmbCuenta.DataTextField = "Cityname";
        cmbCuenta.DataSource = data;
        cmbCuenta.DataBind();
        cmbCuenta.SelectedIndex = 0;
    }
    private static DataTable GetData(SqlCommand selectCommand)
    {
        selectCommand.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
        DataTable data = new DataTable();
        adapter.Fill(data);
        return data;
    }

    Hope this will helps you.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Arnoldo
    Arnoldo avatar
    2 posts
    Member since:
    Nov 2013

    Posted 28 Nov 2013 Link to this post

    Thanks.
    I'm sorry but the RadAjaxManager where it goes, in the principal page or inside the Content2?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Nov 2013 Link to this post

    Hi Arnoldo,

    Please have a look into the following help documentation for RadAjaxManager and RadAjaxManagerProxy and a take a look on this online demo also. 

    Hope this will helps you.
    Thanks,
    Shinu.
Back to Top