Setting focus on control

Discussion in 'ASP .Net' started by Mike, Aug 11, 2004.

  1. Mike

    Mike Guest

    Hi,

    I have a webform with two textboxes and two buttons. I would like to set the focus to the first textbox when the page is displayed. I tried to change the TabIndex, but apparently, it does not have any effect. Any idea on how I could do that?

    Thanks
    Mike
     
    Mike, Aug 11, 2004
    #1
    1. Advertisements

  2. The easiest, most reliable way is client side Javascript:

    MyControl.focus();

    Here's more info:
    http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/ref_f-g.htm#59872

    You might also consider using this free control:
    http://www.metabuilders.com/Tools/FirstFocus.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com


    Hi,

    I have a webform with two textboxes and two buttons. I would like to set the focus to the first textbox when the page is displayed. I tried to change the TabIndex, but apparently, it does not have any effect. Any idea on how I could do that?

    Thanks
    Mike
     
    Steve C. Orr [MVP, MCSD], Aug 11, 2004
    #2
    1. Advertisements

  3. Mike

    Guest Guest

    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.