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

Javascript error selecting radcombobox item

1 Answer 33 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
archimede
Top achievements
Rank 1
archimede asked on 16 Jul 2010, 03:00 PM
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()" />

1 Answer, 1 is accepted

Sort by
0
Accepted
Kalina
Telerik team
answered on 16 Jul 2010, 05:07 PM
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
Tags
General Discussions
Asked by
archimede
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or