Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

Set the TabIndex of each TextBox in a required sequence.


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




Try this..let me know if this is your solution..
 
Share this answer
 
v3
Try using AJAX. Add an update panel, and set focus to password textbox in textchanged event of TextBox 1.

C#
<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>
 
Share this answer
 
Comments
Ubaid ur Rahman IT 20-Jun-12 7:37am    
Please can u show me, how to do this...Thanks
I think if you do the following in the event on server-side it will work. [LAST line of function is important]

C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
   {
       TextBox2.Text = TextBox1.Text;
       TextBox3.Focus();
   }
 
Share this answer
 
Use the below code:

C#
protected void TextBox1_LostFocus(object sender, EventArgs e)
   {
      //Process TextBox 1
       TextBox2.Focus();
   }

 Permalin
 
Share this answer
 
Comments
Sandeep Mewara 22-Jun-12 15:29pm    
in Asp.NET?

Please reply to questions only if you are aware of it and do look at the tags.
Ranjith Reddy CSE 23-Jun-12 1:30am    
Yes, In Asp.net C#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900