setting the focus on a textbox

R

Richard

I have multiple textboxes on a page but when the page loads i want to set
the focus on a particulair textbox so a user can fill in the text right away
without having to click on the textbox to focus it.

Anyone know how?

thx in advance...
 
K

Kevin Spencer

JavaScript:

document.forms[0].elementName.focus();

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
R

Raterus

Put this in page_load

Page.RegisterStartupScript("setFocus", "<script language='javascript'>document.forms[0].txtBoxID.focus();</script>")

--Michael
 
R

Richard

thx, that helped

Richard

"Raterus" <[email protected]> schreef in bericht
Put this in page_load

Page.RegisterStartupScript("setFocus", "<script
language='javascript'>document.forms[0].txtBoxID.focus();</script>")

--Michael
 
G

Guest

How do I write this code in VB?

Thanks

Raterus said:
Put this in page_load

Page.RegisterStartupScript("setFocus", "<script language='javascript'>document.forms[0].txtBoxID.focus();</script>")

--Michael

Richard said:
I have multiple textboxes on a page but when the page loads i want to set
the focus on a particulair textbox so a user can fill in the text right away
without having to click on the textbox to focus it.

Anyone know how?

thx in advance...
 
D

Dan Brussee

How do I write this code in VB?
Put this in page_load

Page.RegisterStartupScript("setFocus", "<script language='javascript'>document.forms[0].txtBoxID.focus();</script>")

Umm... That is VB code. If you are asking how to do the script in VB
code, then, although it is possible to run VB script in the IE
browser, you should probably consider using Javascript instead.
Remember, the code shown runs on the server and generates Javascript
code that is ultimately run immediately after the page loads on the
browser. Javascript is the best tool on the browser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top