Solved

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

Posted on 2011-09-07
4
510 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now