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

RadComboBox methods undefined

1 Answer 48 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Avi
Top achievements
Rank 1
Avi asked on 26 Aug 2008, 01:18 PM
Hi all

When I use the following code I get combo2 as null
var combo2 = $find('<%= rcb_DbPrefixes.ClientID %>');

When I try one of the following I get a get an object
var combo2 = $get('<%= rcb_DbPrefixes.ClientID %>'); 
var combo2 = document.getElementById('<%= rcb_DbPrefixes.ClientID %>');

However, when I try using functions such as:
var item = combo2.findItemByText(text);  
or 
combo2.get_items()

I get that those functions are undefined for the object.  When I look at the object's methods with the debugger I see many methods but non of them are the ones shown above.

What am I doing wrong?

Thanks a million,
Avi

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 28 Aug 2008, 06:04 PM
Hello Avi,

Please try the following code:

javascript
<script language="javascript" type="text/javascript"
    var ajaxCombo; 
    function GetCombo(sender, args) { ajaxCombo = sender; } 
    function ShowItem() { alert(ajaxCombo.get_items().getItem(0).get_text()); } 
</script> 

html
<telerik:RadComboBox ID="ComboAjax" runat="server" OnClientLoad="GetCombo"
    <Items> 
        <telerik:RadComboBoxItem Text="Item1" Value="Item1" /> 
        <telerik:RadComboBoxItem Text="Item2" Value="Item2" /> 
    </Items> 
</telerik:RadComboBox> 
<asp:Button ID="Button1" OnClientClick="ShowItem()" runat="server" Text="Get Item" /> 

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Avi
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or