在按下Enter键的同时从文本框导航到另一个文本框 [英] Navigate from textbox to another textbox while press the enter

查看:110
本文介绍了在按下Enter键的同时从文本框导航到另一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个包含多个网页的母版页.在一页中,我在Web应用程序(ASP.NET 3.5)中有多个文本框.我想在这里,当我按Enter键时,光标将转到另一个文本框.
如何使用C#编码实现此目标?
请指导我..
谢谢!!!!

I am using a master page with multiple of web pages. In one page, i have multiple textbox in web application (ASP.NET 3.5). Here I want, when i press the enter key cursor will goes to another textbox.
How can i implement this using C# coding?
please guide me ..
Thanks !!!

推荐答案

,您可以使用"keypress"事件或"ProcessCmdKey"事件,并将keychar值与"\ n"进行比较,并且可以导航到任何地方
you can use "keypress" event or "ProcessCmdKey" event and compare the keychar value with "\n" and you can navigate to where ever you want.


您可以使用onkeydown事件捕获事件键代码,然后按Tab键代码.

在文本框中尝试这样的操作:
You can use onkeydown event to trap the event keycode and then press tab keycode.

Try something like this for the textbox:
<input type="text" onkeydown="EnterToTab()">


JS代码:


JS code:

function EnterToTab(){
  if (event.keyCode==13)
    event.keyCode=9;
  }



PS:这是不建议使用的,因为Enter和Tab具有两个不同的功能来执行和使用它们,这并不是很好.



PS: This is not suggestible as Enter and Tab have two different functions to perform and playing with them like this not good.


这篇关于在按下Enter键的同时从文本框导航到另一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆