Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Hi All,

I have a textbox in my web application and having login page have user id and password. Now i want that if the page loads then cursor should be on userid textbox.

Please let me know how to do it.

Thanks
Mohd Wasif
Posted
Updated 11-Oct-17 23:19pm

put this on page_load

C#
txtuser.focus();
 
Share this answer
 
v2
Comments
Mohd Wasif 3-Jan-12 2:47am    
Not working.
Mohd Wasif 3-Jan-12 2:49am    
Sorry Working my 5
RaviRanjanKr 3-Jan-12 3:00am    
5+
Try
C#
protected void Page_Load(object sender, EventArgs e)
{
   if (!Page.IsPostBack)
      txtuid.Focus();
}

for more information about getting focus in texbox you can check given reference link
Focusing and Selecting the Text in ASP.NET TextBox Controls
[^]
Default Focuswith Validation Errors with ASP.NET 2.0 [^]
 
Share this answer
 
try the following code in page_Load()
C#
textbox1.focus=true;
 
Share this answer
 
v2
C#
public void message{
}
 
Share this answer
 
Comments
Richard Deeming 12-Oct-17 13:11pm    
What is this, "post random crap to ancient questions" week?!

The question was asked, answered, and solved FIVE AND A HALF YEARS AGO. And your "solution" doesn't even attempt to answer the question.

Keep it up if you want to get banned from the site!

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