Solved

Automatic go to textbox2 when a user gives an enter in textbox1.

Posted on 2011-09-07
4
514 Views
Last Modified: 2013-12-17
Hi,

I have 2 textboxes on my form, one is called textBox1 and the other is
called textBox2. I would like when a user is typing in textBox1 and presses
the enter-key it goes automaticly to textBox2.

How can I go from textBox1 to textBox2 after pressing the enter-key?

Who can help me and know the answer?

Greetings,

Peter Kiers
0
Comment
Question by:peterkiers
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Praveen_Bobbili earned 500 total points
ID: 36494372
Hi,
Give the onkeypress event to textbox1

<input type="text" id="textbox1" onkeypress="optionkeypress(eve);"/>
function optionkeyress(evt)
{
     if(evt.keycode == 13)
       {
txtbox2.focus();
}
 
}
 
 
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36494400
I don't know if it's me but I don't know what I am doing wrong, but i get errors:

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (keycode == 13)
            {
                textBox2.focus();
            }
        }

Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36494441
Gotit:

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                textBox2.Focus();

            }
        }

Greetings,

Peter Kiers
0
 
LVL 1

Expert Comment

by:Praveen_Bobbili
ID: 36494854
May be somewhere you got the conflict with other javascript. Try to do with error console in firefox.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question