SetFocus

Discussion in 'ASP .Net' started by Jurjen de Groot, Jun 29, 2003.

  1. I would like to set the focus automatically to one of the textbox controls
    on my page, but so far on every page I load I have to set the cursor to the
    textbox by Tab-ing or clicking my mouse in it. I would think that there's a
    much simpler way to solve this ...


    regards,

    Jurjen de Groot
    G.I.T.S. Netherlands.
     
    Jurjen de Groot, Jun 29, 2003
    #1
    1. Advertisements

  2. dmedina

    dmedina Guest

    Jurjen de Groot

    Try putting this code at the end of the page,I think it
    goes before the body tag and after the form tag....

    <script language=javascript>
    document.GetElementById('YourTextboxName').focus()
    </script>

    dmedina


    >-----Original Message-----
    >Perry,
    >
    >Thanks for your response.
    >I still have a problem, when I start my ASP.NET project

    the login form
    >appears, but the user has to click in the 'username'

    field (or hit tab a few
    >times) to get the cursor into the username field. I'd

    really like to set the
    >cursor in this field (or ay field for that matter)

    upon 'page load'.
    >
    >I've read the KB article but that uses the focus setting

    after pressing a
    >button. I can't figure out how to use this on something

    like a page load
    >event.
    >
    >Kind regards,
    >
    >Jurjen de Groot
    >G.I.T.S. Netherlands.
    >
    >
    >""Perry Deng"" <> wrote in

    message
    >news:...
    >> At design time, you can use the TabIndex property to

    specify the tab
    >order
    >> of each control in the web page. While at running time,

    you can use the
    >> Focus method to set focus to web control using client-

    side script.
    >>
    >> Please refer to the following article for the sample

    code:
    >> HOW TO: Set Focus to Web Form Controls By Using Client-

    Side Script
    >> http://support.microsoft.com/default.aspx?scid=KB;EN-

    US;816166
    >>
    >> Best regards,
    >> Perry Deng
    >> Microsoft
    >>
    >> This posting is provided "AS IS" with no warranties,

    and confers no
    >rights.
    >>

    >
    >
    >.
    >
     
    dmedina, Jun 30, 2003
    #2
    1. Advertisements

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. jamess

    asp setfocus and performance

    jamess, Oct 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    527
    Saravana [MVP]
    Oct 30, 2003
  2. jaffer the but

    setfocus eh ! help

    jaffer the but, Apr 14, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    662
    Lars Netzel
    Apr 14, 2004
  3. Mad Scientist Jr

    asp.net setfocus after validation not working

    Mad Scientist Jr, Jul 13, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    6,975
    Mad Scientist Jr
    Jul 15, 2004
  4. JC
    Replies:
    2
    Views:
    9,512
  5. =?Utf-8?B?Um9iaW4gWWFybmVsbA==?=

    SmartNav breaks SetFocus client side script

    =?Utf-8?B?Um9iaW4gWWFybmVsbA==?=, Aug 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    572
    jasonkester
    Aug 11, 2005
Loading...

Share This Page