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

RadAjaxManager doesn't work with my radcombobox

3 Answers 126 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Arnoldo
Top achievements
Rank 1
Arnoldo asked on 27 Nov 2013, 10:02 PM
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>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Nov 2013, 03:33 AM
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.
0
Arnoldo
Top achievements
Rank 1
answered on 28 Nov 2013, 02:32 PM
Thanks.
I'm sorry but the RadAjaxManager where it goes, in the principal page or inside the Content2?
0
Shinu
Top achievements
Rank 2
answered on 29 Nov 2013, 04:05 AM
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.
Tags
Ajax
Asked by
Arnoldo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Arnoldo
Top achievements
Rank 1
Share this question
or