Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't show blinking cursor when page opens

Status
Not open for further replies.

olypost

Programmer
Apr 15, 2005
43
US
Hi, I have a very simple asp.net web form page with 3 textboxes and a submit button. When I open this page, there is no cursor appearing in any of the 3 textboxes. When I open the page in a browser, I can manually mouse-click into any of the textboxes, and then the cursor appears (but not blinking).

How do I get the page to open and default with a blinking cursor in one of the 3 textboxes, like when you go to google.com?

Thanks.
 
You have to use javascript. e.g.
Code:
		<script language="JavaScript">
			function setFocus()
			{
				document.Form1.MyTextBox.focus();
			}
		</script>

	<body onload="setFocus()">
You can also use Page.RegisterStartUpScript and register a script like the one above if you want to dynamically set which control has focus.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top