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

Javascript can't find ComboBox

3 Answers 235 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jesse Lawler
Top achievements
Rank 1
Jesse Lawler asked on 09 Jun 2010, 08:53 AM
Okay, so despite the fact that I'm following the Telerik example here to the letter...

var combo = <%= RadComboBox1.ClientID %>;
combo.Items[0].Select();

My Javascript function cannot find my RadComboBox, and when I run the Javascript function with this command in it, I get the error "ctl00_SecondLevelBodyContent_TopLevelTabs_CustomerServiceTab_RadComboBox1 is not defined".  What gives?

[For what it's worth, document.getElementById('<%= RadComboBox1.ClientID %>') evaluates to object HTMLDivElement.]

I just want to be able to grab hold of my ComboBox from the client side, and I'm baffled why the seemingly-basic example on the Telerik website is failing for me.  Thanks for your help.

3 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 09 Jun 2010, 10:04 AM
Hi Jesse Lawler,

You can get the RadComboBox client-side object using this JavaScript code:
var combo = $find("<%= RadComboBox1.ClientID %>");

Please note that the article that you follow is related to RadComboBox for ASP.NET.
The corresponding article for RadComboBox for ASP.NET AJAX you can find here.

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.
0
Jesse Lawler
Top achievements
Rank 1
answered on 09 Jun 2010, 10:37 AM
This still isn't working for me.  This code...

var CustomerComboBox = $find("<%= CustomersID.ClientID %>");
var item = CustomerComboBox.FindItemByText("");
            
...returns the error CustomerComboBox.FindItemByText is not a function.  The $find() command is returning an object, but whatever object it is doesn't seem to be a Telerik RadComboBox object.  What's going on?

One thing that may be relevant:  The RadComboBox is inside of an <asp:Panel> control.  Could that be messing up Javascript's ability to get a handle on the RadComboBox?

Thanks,

Jesse
0
Accepted
Kalina
Telerik team
answered on 09 Jun 2010, 11:47 AM
Hi Jesse Lawler,

The correct name of the function is "findItemByText".
var combo = $find("<%=RadComboBox1.ClientID %>");
var item = combo.findItemByText("test item");

<telerik:RadComboBox ID="RadComboBox1" runat="server">
    <Items>
        <telerik:RadComboBoxItem Text="test item" Value="1" />
    </Items>
</telerik:RadComboBox>

You can find more details about RadComboBox for ASP.NET AJAX client-side API here.

Best wishes,
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
Jesse Lawler
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Jesse Lawler
Top achievements
Rank 1
Share this question
or