onkeyup client event issue on telerik RadInputs ...

3 posts, 0 answers
  1. Majid Darab
    Majid Darab avatar
    112 posts
    Member since:
    Dec 2009

    Posted 20 Jul 2011 Link to this post

    hi dear telerik team :
    i want to copy a textbox text property to another when typing (should be exactly the same)...
    so please see the below codes (copy and paste and Test them) :
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="keyup.Default" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
        <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
        <style type="text/css">
            fieldset
            {
                width:300px;
            }
            legend
            {
                color:Blue;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <div>
            <fieldset>
                <legend>keyup</legend>
                <asp:TextBox ID="TextBox1" runat="server" onkeyup="onkeyup_TextBox1();"></asp:TextBox>
                <br />
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            </fieldset>
            <br />
            <br />
            <fieldset>
                <legend>keydown</legend>
                <asp:TextBox ID="TextBox3" runat="server" onkeydown="onkeydown_TextBox3();"></asp:TextBox>
                <br />
                <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
            </fieldset>
            <br />
            <br />
            <fieldset>
                <legend>keypress</legend>
                <asp:TextBox ID="TextBox5" runat="server" onkeypress="onkeypress_TextBox5();"></asp:TextBox>
                <br />
                <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
            </fieldset>
            <br />
            <br />
            <fieldset>
                <legend>Telerik - keyup</legend>
                <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" DataType="System.Int32"
                    onkeyup="onkeyup_RadNumericTextBox1();">
                    <NumberFormat DecimalDigits="0" />
                </telerik:RadNumericTextBox>
                <br />
                <telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server"
                    DataType="System.Int32" Culture="fa-IR" Width="125px">
                    <NumberFormat DecimalDigits="0" />
                </telerik:RadNumericTextBox>
            </fieldset>
        </div>
            <script type="text/javascript">
                function onkeyup_TextBox1() {
                    $('#TextBox2').val($('#TextBox1').val());
                }
                function onkeydown_TextBox3() {
                    $('#TextBox4').val($('#TextBox3').val());
                }
                function onkeypress_TextBox5() {
                    $('#TextBox6').val($('#TextBox5').val());
                }
                function onkeyup_RadNumericTextBox1() {
                    var RadNumericTextBox1 = $find("<%= RadNumericTextBox1.ClientID %>");
                    var RadNumericTextBox2 = $find("<%= RadNumericTextBox2.ClientID %>");
     
                    RadNumericTextBox2.set_value(RadNumericTextBox1.get_value());
                }
        </script>
        </form>
    </body>
    </html>


    for my purpose onkeyup event on regular asp.net textbox controls is ok...
    but it does n't work sometimes in telerik input controls!(there is no problem about onkeyup syntax , just when typing in first text box the other one have 1 character less , why ?)

    which event should i use for telerik input controls for doing this job?

    thanks in advance

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Jul 2011 Link to this post

    Hello Majid Darab,

    The Ajax controls (all of our controls from the RadControls for ASP.NET Ajax suite) expect an object of type function for their client-side events. So on the Onkeyup event you only need to give the  function name.
    Onkeyup="Onkeyup_RadNumericTextBox1".

    Thanks,
    Princy.
  3. Majid Darab
    Majid Darab avatar
    112 posts
    Member since:
    Dec 2009

    Posted 20 Jul 2011 Link to this post

    dear Princy thanks for answer ...
    i test your code / but it did n't work at all/ your answer is true about telerik client events (you can find them in properties area)
    but i used regular asp.net onkeyup(not specially only for telerik controls) and it needs (); at the end of function name...
    at the other side -> is there any difference between onkeyup and Onkeyup ?(mean lower case and upper case of o character)?
    also i update my question (nothing wrong about syntax and every thing about that is ok)

    thanks in advacne
Back to Top