Can't access combo inside panel from client side

3 posts, 1 answers
  1. Bodie Sullivan
    Bodie Sullivan avatar
    2 posts
    Member since:
    Aug 2009

    Posted 06 Oct 2010 Link to this post

    I have two comboboxes that are inside a panel control. The panel's visibility is false initially. When the user selects an option, the panel with the 2 combo boxes is made visible. Depending on what the user selects in the first combo box, I need to enable or disable the second combo box client side. However, I am unable to access the combo using $find('<%= cbxAdminAction.ClientID %>'). 

    I have also tried accessing the combo boxes usingTelerik.Web.UI.RadComboBox.ComboBoxes. I was able to find the combo controls in the Firebug console. However, when the page loads, Telerik.Web.UI.RadComboBox.ComboBoxes[14] is out of range.

    How do I access the combo boxes from client side?

    The function below is wired to the onClientSelectedIndexChanged event for the first combo box.

    01.function EnableSubActionDropDown(combo, eventArgs)
    02.{
    03.   var value = Telerik.Web.UI.RadComboBox.ComboBoxes[14].get_value();
    04.          
    05.     if (value != "99")
    06.     {
    07.        Telerik.Web.UI.RadComboBox.ComboBoxes[15].disable;
    08.      }
    09.      else
    10.      {
    11.        Telerik.Web.UI.RadComboBox.ComboBoxes[15].enable;
    12.      }
    13.}

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Oct 2010 Link to this post

    Hello Bodie,

    I am not quite sure about your scenario. Similar code I have tried in my application and it is working fine at my end. I have pasted the code below. Check whether you have set the Visible property of RadComboBox as 'False'.
    ASPX:
    <asp:Panel ID="Panel2" runat="server">
      <telerik:RadComboBox ID="RadComboBox3" runat="server" Width="190px" DataSourceID="SqlDataSource3" DataTextField="CategoryID" DataValueField="CategoryID" OnClientSelectedIndexChanged="SelectedIndexChanged">
      </telerik:RadComboBox>
      <telerik:RadComboBox ID="RadComboBox4" runat="server" Width="190px" DataSourceID="SqlDataSource3" DataTextField="CategoryName" DataValueField="CategoryName">
      </telerik:RadComboBox>
    </asp:Panel>

    Java Script:
    <script type="text/javascript">
        function SelectedIndexChanged(sender, args) {
            var combo2 = $find("<%=RadComboBox4.ClientID %>");
            if (sender.get_value() == 3)
                combo2.set_enabled(false);
            else
                combo2.set_enabled(true);
        }
    </script>


    Could you paste your code if it does not help?

    Thanks,
    Princy.
  3. Answer
    Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 12 Oct 2010 Link to this post

    Hi Bodie,

    Let me suggest you declare one global client-side variable to hold the RadComboBox object instance and initialize it at OnClientLoad event of the control:
    <script type="text/javascript">
     
        var comboAdminAction;
         
        function OnClientLoadHandler(sender)
        {
            comboAdminAction = sender;
        }
    </script>
    <telerik:RadComboBox ID="cbxAdminAction" runat="server"
        OnClientLoad="OnClientLoadHandler">
     ...

    Then simply use this variable in your client-side scripts.

    Greetings,
    Kalina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top