按Tab键时如何在文本框中输入数据 [英] how to entry data in text box when press the tab key

查看:225
本文介绍了按Tab键时如何在文本框中输入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i在asp.net中使用c#我在
中使用

 <   asp:TextBox     ID   =  txtEmpCode    runat   =  server   宽度  =  180px    AutoPostBack   =  true   正文  ='  <%# Eval(  empl_code%> '  

< span class =code-attribute> 样式 = text-transform:uppercase OnTextChanged = txtEmpCode_TextChanged > < / asp :TextBox >









和我的重复是当我在第一个文本框中打开光标页面,然后我按Tab键移动并移动其他,当我点击保存按钮点击我的数据是保存,我的光标移动第一个文本框,



但我的问题是我的所有测试框autopostback属性是真的它的文本改变我执行一些活动,那是由我失去了光标,





请帮助我紧急请

解决方案

< blockquote>你有AutoPostBack = True的所有文本框,但为什么?

如果它的要求及其发生在y上然后你正在处理每个文本框的textchange事件处理程序,你已经知道回发后哪个文本框应该有光标。您可以使用javascript来设置焦点。只需创建一个使用Page.RegisterClientScriptBlock注册客户端脚本的函数。

Javascript函数示例:

http://stackoverflow.com/questions/45827/how-do-you-automatically-set-the-focus-to-a-textbox-什么时候网页加载 [ ^ ]






在保存按钮代码中添加:

  protected   void  BtnSave_Click( object  _ObjSender,EventArgs e)
{
尝试
{
TxtFirstTextBox.Focus();
}
catch
{

}
}


hi,

i am working in asp.net with c# i used in

<asp:TextBox ID="txtEmpCode" runat="server" Width="180px" AutoPostBack="true" Text='<%#Eval("empl_code") %>'

                                                                       Style="text-transform: uppercase" OnTextChanged="txtEmpCode_TextChanged"></asp:TextBox>





and my recuriment is that when i page in open cursor set in first text box,and then i press tab key its shift and shift other, and when i click save button click my data is save and my cursor is shift first text box,

but my probel is that my all test box autopostback properites is true and its text change i perform some activity, thats by i lost the cursor,


please help me its urgent please

解决方案

You have all text boxes with AutoPostBack=True, but Why?
If its the requirement and its happening on your page then you are handling each textbox's textchange event handler and you already know which text box is should have the cursor after postback. You can use javascript to set the focus. Just create a function which registers client script using Page.RegisterClientScriptBlock.
Javascript functions example:
http://stackoverflow.com/questions/45827/how-do-you-automatically-set-the-focus-to-a-textbox-when-a-web-page-loads[^]


Hi,

On your save button code add this:

protected void BtnSave_Click(object _ObjSender, EventArgs e)
      {
          try
          {
           TxtFirstTextBox.Focus();
          }
          catch
          {

          }
      }


这篇关于按Tab键时如何在文本框中输入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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