本文介绍了文本框自动聚焦到其他文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在Asp.net,C#,SqlServer2005上工作.

我的登录页面上有3个文本框和一个提交"按钮

============================
用户名:TextBox1
DisplayName:Textbox2
密码:Textbox3


提交

============================

在此,我将Textbox1属性的AutoPostback设置为TRUE,并在Textbox1 TextchangedEvent中编写了代码.以便在Textbox2中显示全名....效果很好.


现在我的问题是文本框焦点问题......
当用户在Textbox1中输入用户名"时,下一个焦点"必须转到密码...",并避免在输入用户名后刷新页面.


请帮帮我,

谢谢.

Dear All,

Am Working on Asp.net, C#, SqlServer2005.

I have 3 Textboxes and a Submit Button on my Login Page

==============================
UserName : TextBox1
DisplayName : Textbox2
Password : Textbox3


Submit

==============================

In this I gave Textbox1 property as AutoPostback to TRUE and wrote code in Textbox1 TextchangedEvent. so that it dispalys a full name in Textbox2....its works fine.


Now My PROBLEM is Textbox Focus Problem......
When the user enters Username in Textbox1 and then the Next focus must go to Password... and avoid page refresh after entering username.


Please help me,

Thanks.

推荐答案

TextBox1.TabIndex=1;
TextBox2.TabIndex=2;





试试这个.让我知道这是否是您的解决方案.





Try this..let me know if this is your solution..


<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown" />
<asp:updatepanel id="updatePanel" runat="server" xmlns:asp="#unknown">
<contenttemplate>

<asp:textbox id="txtUserName" runat="server"></asp:textbox>
<asp:textbox id="txtDisplayName" runat="server"></asp:textbox>
<asp:textbox id="txtPassword" runat="server"></asp:textbox>

</contenttemplate>
</asp:updatepanel>


protected void TextBox1_TextChanged(object sender, EventArgs e)
   {
       TextBox2.Text = TextBox1.Text;
       TextBox3.Focus();
   }


这篇关于文本框自动聚焦到其他文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 04:50
查看更多