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

Can't access combo inside panel from client side

2 Answers 101 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bodie Sullivan
Top achievements
Rank 2
Bodie Sullivan asked on 06 Oct 2010, 03:34 PM

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 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Oct 2010, 02:59 PM
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.
0
Accepted
Kalina
Telerik team
answered on 12 Oct 2010, 11:39 AM
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
Tags
ComboBox
Asked by
Bodie Sullivan
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Kalina
Telerik team
Share this question
or