Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
tell me answer bgthn yn 56y 56yu ......
Posted
Comments
faisal23 7-Nov-12 7:13am    
Directly set focus on that text box on form load
Member 9579525 7-Nov-12 7:18am    
than u...i have tried that but it wont work....i have to click for enter value in it..
faisal23 7-Nov-12 7:21am    
no thats not happen.
Use on form load or other way is tab index set to 0.
Member 9579525 7-Nov-12 7:25am    
thanks...
SoumenBanerjee 7-Nov-12 8:14am    
You can try this..
if (!Page.IsPostBack)
txtName.Focus();

1 solution

You can also write a piece of code in HTML in body tag

< body önload="javascript:document.form.textbox.focus();">
. . .
</body>


This code can be used only in independent page i.e, no master page should be involved.
You can use the following syntax in child pages or independent page.

textbox.Focus();
 
Share this answer
 
v2

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