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

7 posts, 1 answers
  1. Nick
    Nick avatar
    7 posts
    Member since:
    Oct 2010

    Posted 20 Oct 2010 Link to this post

    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>
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Oct 2010 Link to this post

    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.
  3. Nick
    Nick avatar
    7 posts
    Member since:
    Oct 2010

    Posted 20 Oct 2010 Link to this post

    *Sigh..*
    Programming can sometimes be so easy...

    Thanks Shinu :-)
  4. Ken Jones
    Ken Jones avatar
    41 posts
    Member since:
    Sep 2009

    Posted 21 Oct 2010 Link to this post

    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
  5. Ken Jones
    Ken Jones avatar
    41 posts
    Member since:
    Sep 2009

    Posted 21 Oct 2010 Link to this post

    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
  6. Yana
    Admin
    Yana avatar
    4806 posts

    Posted 22 Oct 2010 Link to this post

    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
  7. Ken Jones
    Ken Jones avatar
    41 posts
    Member since:
    Sep 2009

    Posted 22 Oct 2010 Link to this post

    OK, cheers.
Back to Top