Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 4 textbox where first 3 textbox take integer value and 4th textbox show there addition result. I make all textbox's autopost back property true because I need to add immediately when text change into any textbox. Problem is when I type one textbox and try to switch another then the cursor focus lost from the 2nd textbox. Please someone help to get cursor on the next textbox after postback. Here I my code.
ASP.NET
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
    </ContentTemplate>
</asp:UpdatePanel>
Posted

when webpage load write below code :
C#
this.textbox1.Focus();
 
Share this answer
 
v3
Comments
Karthik_Mahalingam 16-Dec-13 10:30am    
good
Gaurav Makwana 16-Dec-13 23:07pm    
thank you karthik
You can do it in a variety of ways:

I you are using HTML5 all you need to do is use the autofocus property.

If you are using any JS thats being called on page load you can explicitly specify it using jquery
PHP
$('#textboxID').focus();


or you can use the server textbox control property in the page load;
C#
this.textboxName.focus();
 
Share this answer
 
v3
Comments
Karthik_Mahalingam 16-Dec-13 10:30am    
good

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