Javascript can't find ComboBox

4 posts, 1 answers
  1. Jesse Lawler
    Jesse Lawler avatar
    46 posts
    Member since:
    Apr 2010

    Posted 09 Jun 2010 Link to this post

    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.
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 09 Jun 2010 Link to this post

    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.
  3. Jesse Lawler
    Jesse Lawler avatar
    46 posts
    Member since:
    Apr 2010

    Posted 09 Jun 2010 Link to this post

    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
  4. Answer
    Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 09 Jun 2010 Link to this post

    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.
Back to Top