Rad Numeric textbox OnBlur event

4 posts, 0 answers
  1. jeevitha
    jeevitha avatar
    63 posts
    Member since:
    Sep 2008

    Posted 13 May 2010 Link to this post

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

    Posted 13 May 2010 Link to this post

    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.

  3. Dimo
    Admin
    Dimo avatar
    8486 posts

    Posted 13 May 2010 Link to this post

    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.
  4. jeevitha
    jeevitha avatar
    63 posts
    Member since:
    Sep 2008

    Posted 13 May 2010 Link to this post

    It Works great ! thanks a lot
Back to Top