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

set_value() method does not work

7 Answers 581 Views
Input
This is a migrated thread and some comments may be shown as answers.
adi
Top achievements
Rank 1
adi asked on 14 May 2009, 08:56 PM
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.

7 Answers, 1 is accepted

Sort by
0
Cradz
Top achievements
Rank 1
answered on 14 May 2009, 11:54 PM
 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!
0
Accepted
Nikolay Rusev
Telerik team
answered on 15 May 2009, 05:10 AM
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.
0
Cradz
Top achievements
Rank 1
answered on 15 May 2009, 04:01 PM
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..
0
asim
Top achievements
Rank 1
answered on 05 Aug 2009, 06:13 AM
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
0
Nikolay Rusev
Telerik team
answered on 05 Aug 2009, 07:19 AM
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.
0
asim
Top achievements
Rank 1
answered on 05 Aug 2009, 08:05 AM
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

0
Jon
Top achievements
Rank 1
answered on 18 Aug 2009, 12:31 PM
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
Tags
Input
Asked by
adi
Top achievements
Rank 1
Answers by
Cradz
Top achievements
Rank 1
Nikolay Rusev
Telerik team
asim
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Share this question
or