setting the focus on a textbox

Discussion in 'ASP .Net' started by Richard, Jul 21, 2004.

  1. Richard

    Richard Guest

    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...
    Richard, Jul 21, 2004
    #1
    1. Advertising

  2. JavaScript:

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

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

    "Richard" <> wrote in message
    news:...
    > 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...
    >
    >
    Kevin Spencer, Jul 21, 2004
    #2
    1. Advertising

  3. Richard

    Raterus Guest

    Put this in page_load

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

    --Michael

    "Richard" <> wrote in message news:...
    > 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...
    >
    >
    Raterus, Jul 21, 2004
    #3
  4. Richard

    Richard Guest

    thx, that helped

    Richard

    "Raterus" <> schreef in bericht
    news:...
    Put this in page_load

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

    --Michael

    "Richard" <> wrote in message
    news:...
    > 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...
    >
    >
    Richard, Jul 21, 2004
    #4
  5. How do I write this code in VB?

    Thanks

    "Raterus" wrote:

    > Put this in page_load
    >
    > Page.RegisterStartupScript("setFocus", "<script language='javascript'>document.forms[0].txtBoxID.focus();</script>")
    >
    > --Michael
    >
    > "Richard" <> wrote in message news:...
    > > 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...
    > >
    > >

    >
    =?Utf-8?B?Um9ic29uIENhcnZhbGhvIE1hY2hhZG8=?=, Aug 8, 2004
    #5
  6. Richard

    Dan Brussee Guest

    >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.
    Dan Brussee, Aug 8, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Durzi

    Setting Focus on an asp:textbox

    George Durzi, Aug 20, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    587
    Marina
    Aug 20, 2003
  2. test test

    setting focus to a textbox

    test test, Aug 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,750
    Kevin Spencer
    Aug 30, 2003
  3. Jason
    Replies:
    4
    Views:
    1,617
    Jason
    May 7, 2007
  4. Replies:
    2
    Views:
    336
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    321
Loading...

Share This Page