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

Rad Numeric textbox OnBlur event

3 Answers 247 Views
Input
This is a migrated thread and some comments may be shown as answers.
jeevitha
Top achievements
Rank 1
jeevitha asked on 13 May 2010, 05:41 AM
Hi,

I am using two numeric text boxes and in the onblur event of one textbox i need to assign the value in the next text box. But the value not setting properly. the SetValue not working. Object reference error is coming, Please help me to sort out the prolemm
my code is
 <telerik:RadNumericTextBox ID="textBoxVarFirstChildR"  Width="75px"  onblur="duplicateFirstChildR();" 
                                                            MaxLength="8" runat="server" /> 
in my java script :
 duplicateFirstChildR() { 
                var textBoxVarFirstChildR = "<%=textBoxVarFirstChildR.ClientID %>"
                var textBoxVarFirstChildNR = "<%=textBoxVarFirstChildNR.ClientID %>"
                var fValue = $find(textBoxVarFirstChildR).GetValue(); 
                $find(textBoxVarFirstChildNR).SetValue(fValue); 
            } 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 May 2010, 07:48 AM

Hello Jeevitha,

Since you are using RadControls for ASP.NET AJAX version, use the get_value()/set_value() methods for getting and setting the value from client code.

ASPX:

 
<telerik:RadNumericTextBox ID="textBoxVarFirstChildR" Width="75px" MaxLength="8"  
    runat="server">  
    <ClientEvents OnBlur="duplicateFirstChildR" />  
</telerik:RadNumericTextBox>  
<telerik:RadTextBox ID="textBoxVarFirstChildNR" runat="server">  
</telerik:RadTextBox> 

JavaScript:

 
<script type="text/javascript">  
    function duplicateFirstChildR(sender, args) {  
        var textBoxVarFirstChildR = "<%=textBoxVarFirstChildR.ClientID %>";  
        var textBoxVarFirstChildNR = "<%=textBoxVarFirstChildNR.ClientID %>";  
        var fValue = $find(textBoxVarFirstChildR).get_value();  
        $find(textBoxVarFirstChildNR).set_value(fValue);  
    }  
</script> 

 

The following documentation shows the most important properties/methods of the RadNumericTextBox client-side object:

RadNumericTextBox Client Object

-Shinu.

0
Dimo
Telerik team
answered on 13 May 2010, 07:51 AM
Hello Jeevitha,

You are not using the correct API. SetValue() is a method of the old ("classic") RadNumericTextBox. Now you have to use set_value().

http://www.telerik.com/help/aspnet-ajax/input_clientsideradnumerictextbox.html

In addition, it is better and more convenient to subscribe to OnBlur like this:

<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server">
    <ClientEvents OnBlur="duplicateFirstChildR"  />
</telerik:RadTextBox>

http://www.telerik.com/help/aspnet-ajax/input_clientsideonblur.html

In this way you will have the textbox client object as a parameter (sender) ready to be used (no need to execute $find() ).

Regards,
Dimo
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
jeevitha
Top achievements
Rank 1
answered on 13 May 2010, 09:10 AM
It Works great ! thanks a lot
Tags
Input
Asked by
jeevitha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dimo
Telerik team
jeevitha
Top achievements
Rank 1
Share this question
or