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

using javascript functions get_text() and set_text() gives an error

6 Answers 399 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 20 Oct 2010, 11:22 AM
Hello,

I'm having a problem with the javascript functions set_text() and get_text() functions.
Below is a simple page to demonstrate. When I click the button I get an error saying " Object doesn't support this property or method"
I've already searched the forums but none of the existing topics helped me out.

Thanks in advance for any tips!
Regards,
Jasper

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Tests_Test" MasterPageFile="~/MasterPageEmpty.master" %>
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ MasterType VirtualPath="~/MasterPageEmpty.master" %>
  
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">   
  <script language="javascript" type="text/javascript">
   function Test() {
     var combo = $find('<%=RadComboBox1.ClientID%>');
     alert(combo.get_Text());
   }
  </script>
</telerik:RadScriptBlock>
  
  <atlas:UpdatePanel ID="UpdatePanel" runat="server">
    <ContentTemplate>
      <telerik:RadComboBox ID="RadComboBox1" runat="server" DataTextField="CompanyName"
        DataValueField="ID" ItemRequestTimeout="500" Height="300px" NoWrap="true" ShowDropDownOnTextboxClick="false"
        EnableLoadOnDemand="True" EnableItemCaching="true" OnItemsRequested="OnSupplierItemsRequested"
        >
      </telerik:RadComboBox>
        
      <button onclick="Test()">Test</button>
        
    </ContentTemplate>
  </atlas:UpdatePanel>
</asp:Content>

6 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 20 Oct 2010, 11:33 AM
Hello Jasper,


Since JavaScript is case sensitive, you must be careful when calling the method and variables. From your code, I can see that you usedget_Text() instead of get_text().

Try the following code:
function Test() {
  var combo = $find('<%=RadComboBox1.ClientID%>');
  alert(combo.get_text());
}



-Shinu.
0
Nick
Top achievements
Rank 1
answered on 20 Oct 2010, 12:59 PM
*Sigh..*
Programming can sometimes be so easy...

Thanks Shinu :-)
0
Ken Jones
Top achievements
Rank 1
answered on 21 Oct 2010, 09:56 PM
Hello,

I am attempting something similat but cant get the code to work other than in an event of the ComboBox, see below:

var cmbType = $get('<%= uiRadCmbContentType.ClientID %>');
alert(cmbType.get_text());

This is running in a user control on a aspx page, using 2009 Q2 controls. I get the standard object does not support this property or method error if I use get_text() or get_value().

Any thoughts?

THanks,

Ken
0
Ken Jones
Top achievements
Rank 1
answered on 21 Oct 2010, 10:34 PM
I've just managed to use .value as opposed to .get_value().

Not sure if this is to do with the version of the control.

Thanks,

KEn
0
Yana
Telerik team
answered on 22 Oct 2010, 01:46 PM
Hi Ken,

You should use $find method to access the client-side object of RadComboBox (not $get). $get returns its DOM element.

Best wishes,
Yana
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
Ken Jones
Top achievements
Rank 1
answered on 22 Oct 2010, 05:14 PM
OK, cheers.
Tags
ComboBox
Asked by
Nick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nick
Top achievements
Rank 1
Ken Jones
Top achievements
Rank 1
Yana
Telerik team
Share this question
or