How to set first focus on specific textbox?

Discussion in 'ASP .Net' started by ABC, Oct 4, 2005.

  1. ABC

    ABC Guest

    How to set first focus on specific textbox?
    ABC, Oct 4, 2005
    1. Advertisements

  2. ABC

    Onin Tayson Guest

    Hi ABC,

    you can use the <body>'s onload event. i.e.

    <body onload="javascript: document.form1.TextBox1.focus();">

    Onin Tayson, Oct 4, 2005
    1. Advertisements

  3. You can do it with javascript. Make sure your form tag has a name attibute,
    e.g. for the example below name="userform"

    <script language="javascript" type="text/javascript">

    You can't do it with server-side code though.
    Leon Mayne [MVP], Oct 4, 2005
  4. ABC

    bienwell Guest


    How can we focus on the field after the form validation. For example, user
    enter wrong data type on the field after validation
    (RegularExpressionvalidator), and I'd like to focus on that field again ???

    bienwell, Nov 17, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.