Thursday, March 22, 2012

setting the focus on a textbox

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...>How do I write this code in VB?
>
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.
java script:
document.forms[0].elementName.focus();
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Richard" <richard@.nospam.com> wrote in message
news:e8ZvBd2bEHA.716@.TK2MSFTNGP11.phx.gbl...
> 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...
>
Put this in page_load
Page.RegisterStartupScript("setFocus", "<script =
language=3D'javascript'>document.forms[0].txtBoxID.focus();</script>")
--Michael
"Richard" <richard@.nospam.com> wrote in message =
news:e8ZvBd2bEHA.716@.TK2MSFTNGP11.phx.gbl...
> 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.
>=20
> Anyone know how?
>=20
> thx in advance...
>=20
>
thx, that helped
Richard
"Raterus" <raterus@.spam.org> schreef in bericht
news:eKh8Vn2bEHA.2476@.TK2MSFTNGP09.phx.gbl...
Put this in page_load
Page.RegisterStartupScript("setFocus", "<script
language='javascript'>document.forms[0].txtBoxID.focus();</script>")
--Michael
"Richard" <richard@.nospam.com> wrote in message
news:e8ZvBd2bEHA.716@.TK2MSFTNGP11.phx.gbl...
> 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...
>
How do I write this code in VB?
Thanks
"Raterus" wrote:

> Put this in page_load
> Page.RegisterStartupScript("setFocus", "<script language='javascript'>docu
ment.forms[0].txtBoxID.focus();</script>")
> --Michael
> "Richard" <richard@.nospam.com> wrote in message news:e8ZvBd2bEHA.716@.TK2MS
FTNGP11.phx.gbl...
>

0 comments:

Post a Comment