make enter key作为Textbox上的Tab键 [英] make enter key act as Tab key on Textbox

查看:69
本文介绍了make enter key作为Textbox上的Tab键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii,



我制作了一个网络应用程序。在这个我想添加一个形式,如用户按下回车键,它将作为标签键。



所以,我将如何解决...



请帮我搞清楚.......



谢谢和问候......

Mitesh

解决方案

您应该订阅控件的KeyPress事件。以下是文本框处理程序的示例:

  private   void  textbox1_KeyPress( object  sender,KeyPressEventArgs e)
{
if (e.KeyChar ==( char )Keys.Return)
base 。 ProcessDialogKey(Keys.Tab);
}



使用这种方法,输入焦点可以切换到例如用户在一个文本框中按Enter键时的下一个文本框。


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



在文本框中尝试这样的事情:

  <  输入    type   =  text    onkeydown   =  EnterToTab() >  



JS代码:

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





PS:这是不可取的,因为Enter和Tab有两个不同的功能像这样表现和玩耍不好。


这可以在网络应用程序中使用JQuery来完成





 <  !DOCTYPE     html     PUBLIC     -  // W3C // DTD     XHTML     1.0     Transitional // EN    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >  

< html xmlns = http://www.w3.org/1999/xhtml >
< head runat = server >
< title > < / title >
< script src = 脚本/ jquery-1.4.1.js type = text / javascript > < / script >

< script 类型 = text / javascript >

hii,

I make a web application. in this i want to add in a form like when user press the enter key it will act as tab key.

so, how this i will solve...

please help me to make out.......

Thanks and Regards...
Mitesh

解决方案

You should subscribe to the KeyPress event of your control. Here is an example of the handler for a textbox:

private void textbox1_KeyPress(object sender, KeyPressEventArgs e)
{
   if (e.KeyChar == (char)Keys.Return)
      base.ProcessDialogKey(Keys.Tab);
}


Using this approach it is very convenient that the input focus can switch to e.g. the next textbox when the user presses enter in one textbox.


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 code:

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



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


This can be done in using JQuery in web application


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>

 <script type="text/javascript">


这篇关于make enter key作为Textbox上的Tab键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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