Javascript error selecting radcombobox item

2 posts, 1 answers
  1. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 16 Jul 2010 Link to this post

    I have an error retrieving the selected radcombobox item (clientside). Why doen't work? I receive error "Error: Object doesn't support this property or method"

    http://www.telerik.com/help/aspnet-ajax/combo_clientsideradcombobox.html

    This is my test page:

    <script type="text/javascript">
            function getValue() {
                var combo = <%=RadComboBox1.ClientID %>; 
      
                alert('1');
                  
                var sel = combo.get_selectedItem();
                  
            }  
        </script>
        <telerik:RadComboBox ID="RadComboBox1" runat="server">
            <Items>
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1" />
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="RadComboBoxItem2" />
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="RadComboBoxItem3" />
            </Items>
        </telerik:RadComboBox>
        <input id="Button1" type="button" value="button" onclick="getValue()" />
  2. Answer
    Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 16 Jul 2010 Link to this post

    Hello archimede,

    Please use $find("<%= RadComboBox1.ClientID %>"); instead of  <%=RadComboBox1.ClientID %>;.

    <script type="text/javascript">
        function getValue() {
            var combo = $find("<%=RadComboBox1.ClientID %>");
            alert('1');
            var sel = combo.get_selectedItem();
            alert(sel.get_text());
        
    </script>
     
    <telerik:RadComboBox ID="RadComboBox1" runat="server">
        <Items>
            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1" />
            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="RadComboBoxItem2" />
            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="RadComboBoxItem3" />
        </Items>
    </telerik:RadComboBox>
    <input id="Button1" type="button" value="button" onclick="getValue()" />


    All the best,
    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. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top