Results 1 to 3 of 3

Thread: Setting the default focus on a web control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90

    Setting the default focus on a web control

    Please forgive what seems to me a very simple question, but, in VB6 I know how to set the default focus on a specific control when the page starts up. However, how do I do this on an ASP.net page? I have tried all the properties I can think of and I just can not get it to work. I have looked in all the books I have and nothing on "focus". Please help.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Well, I don't know of ASP.Net way, but Javascript works fine. If you need to know how to do it, check out www.google.com. They make the focus go to the textbox when the page loads through Javascript. Here is their function:
    Code:
    <script>
    <!--
    function sf(){document.f.q.focus();}
    // -->
    </script>
    
    <body onLoad=sf()>
    Just to note, f is the name of the form, and q is the textbox.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90
    That worked! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width