RadNumericTextBox > OnKeyPress > set_keyCode?

4 posts, 0 answers
  1. Nelson
    Nelson avatar
    15 posts
    Member since:
    Jan 2011

    Posted 01 Sep 2013 Link to this post

    Hi,

    I would like to capture the "Enter" keypress and move the control from one "RadNumericTextBox" to "RadNumericTextBox",  is set_keycode not working? The code stop at the set_keycode in the javascript function call.

    Cheers, 
    Nelson
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Sep 2013 Link to this post

    Hi Nelson,

    Please have a look at the following code I tried which works fine at my end.

    ASPX:
    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" onKeyDown="checkEnter()">
    </telerik:RadNumericTextBox>
    <br />
    <telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server" onKeyDown="checkEnter()">
    </telerik:RadNumericTextBox>
    <br />
    <telerik:RadNumericTextBox ID="RadNumericTextBox3" runat="server" onKeyDown="checkEnter()">
    </telerik:RadNumericTextBox>

    JavaScript:
    <script type="text/javascript">
        function checkEnter() {
            if (event.keyCode == 13) {
                event.keyCode = 9;
            }
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nelson
    Nelson avatar
    15 posts
    Member since:
    Jan 2011

    Posted 02 Sep 2013 Link to this post

    Thanks Shinu. But what i want is when user press "Enter" in the textbox control, the system will move the focus to the next one just like pressing the "Tab". Is it possible?

    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" onKeyDown="MoveNext(this,event)">
    </telerik:RadNumericTextBox>
    <br />
    <telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server" onKeyDown="MoveNext(this,event)">
    </telerik:RadNumericTextBox>
    <br />
    <telerik:RadNumericTextBox ID="RadNumericTextBox3" runat="server" onKeyDown="MoveNext(this,event)">
    </telerik:RadNumericTextBox>


            <script type="text/javascript">
                function MoveNext(sender, args) {
                    
                    //alert(args);
                    var key = args.get_keyCode();
                    alert(key);
                    if (args.get_keyCode() == 13) {
                        args.set_cancel(true);
                        alert('a');
                        args.set_keyCode() = 9;
                        alert('b');
                    }
                    
                }
            </script>
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Sep 2013 Link to this post

    Hi Nelson,

    You cannot retrieve the key code using get_keyCode() since the args does not have one such JavaScript method. You can always use the event.keyCode always returns the key code of the current pressed key. Please try the code I posted in my previous reply which works fine for your scenario.

    Thanks,
    Shinu.
Back to Top