set_value() method does not work

8 posts, 1 answers
  1. adi
    adi avatar
    81 posts
    Member since:
    Feb 2007

    Posted 14 May 2009 Link to this post

    Hi,

    I have a RadTextbox and I'd like to set the value with javascript. Here is my code:
                var textbox = $get('<%= RadTextbox1.ClientID%>' + '_text');  
                textbox.set_value('Test');  
     

    But I get an error message Object doesn't support this property or method and if I look in detail I can't find any method like set_value in my object on textbox. I use the last Asp.Net Ajax Controls version.
  2. Cradz
    Cradz avatar
    65 posts
    Member since:
    Nov 2005

    Posted 14 May 2009 Link to this post

     I'm looking for help similar to this as I update the value via Javascript and with a normal ASP textbox it updates correctly but with an AJAX enabled RadTextbox it doesn't...

    I figured a way around it by setting textbox_value.value = "My Text" but the postback doesn't fire. Grrr!
  3. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 15 May 2009 Link to this post

    Hi ,

    $get will is alias of document.getElementById, thus $get('<%= RadTextbox1.ClientID%>' + '_text');   will return html element that is actual editable element in RadTextBox

    To get reference to RadTextBox client object and to be able to use client API you should use the code below:

    var textBox = $find("<%=RadTextBox1.ClientID %>");  
    textBox.set_value("my value"); 


    Best wishes,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. Cradz
    Cradz avatar
    65 posts
    Member since:
    Nov 2005

    Posted 15 May 2009 Link to this post

    Thanks Nikolay.

    I moved my Javascript function out of a js file and into the page itself using your version and now the Callback works correctly..
  5. asim
    asim avatar
    4 posts
    Member since:
    Jun 2009

    Posted 05 Aug 2009 Link to this post

    when i write the following code

    var textBox = $find("<%=RadTextBox1.ClientID %>");
    textBox.set_value("my value"); 

    after the execution textbox is equal to null. and an error occurs 'null is null or not an object'.
    Nikolay please help me.

    Regards,

    Asim
  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 05 Aug 2009 Link to this post

    Hello asim,

    I am attaching sample page that demonstrates how this $find works.
    It find RadTextBox and set some value on pageLoad client event.

    Regards,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. asim
    asim avatar
    4 posts
    Member since:
    Jun 2009

    Posted 05 Aug 2009 Link to this post

    Thanks alot Nikolay.

    Now I want to change the other properties of asp Link Button like 'Commandname' etc. in Javascript. So please tell me how can i do it.


    Regards,

    Asim

  8. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 18 Aug 2009 Link to this post

    Hi All,

    I too was just having the issue where the $find returns a null value.  To save other people time if they find this and want to know what to do, remember to put the $find for the textbox in the page load event.  Mine was running before the page was 100% loaded, as such the control hadn't rendered properly yet.

    Cheers,

    Jon
Back to Top