How to get Focus on one Button,if two buttons exists on the same form

Discussion in 'ASP .Net' started by ravindradonkada@gmail.com, Oct 3, 2006.

  1. Guest

    Hi,
    I am Ravindra,presently doing a project in asp.net.
    The Login page of my Web Project consists of two Buttons.
    If user enters his username and password and clicks on enter button
    of keyboard,
    the Signin button is to be submitted not the other button.
    So,please specify how to get focus on the specified
    Button
    Thanks in advance.

    Ravindra
    , Oct 3, 2006
    #1
    1. Advertising

  2. for example you have
    a btnLogin (as the default button that needs to be press in order to login)
    and a txtPassword text field (as well a txtUsername, but this you can
    populate using cookies)

    this code under Page_Load
    Page.Form.DefaultButton = btnLogin.UniqueID
    Page.Form.DefaultFocus = txtPassword.UniqueID

    will make btnLogin to be your default button (when someone presses Enter)
    to be used as submiting the form
    and it will get the txtPassword field the focus (so the cursor will blink in
    that textfield)

    the defaultButton does not work under Firefox cause a bug that is not solved
    yet, but works fine under IE.


    --

    Bruno Alexandre
    KĂžbenhavn, Danmark

    "a portuguese in Denmark"


    <> escreveu na mensagem
    news:...
    > Hi,
    > I am Ravindra,presently doing a project in asp.net.
    > The Login page of my Web Project consists of two Buttons.
    > If user enters his username and password and clicks on enter button
    > of keyboard,
    > the Signin button is to be submitted not the other button.
    > So,please specify how to get focus on the specified
    > Button
    > Thanks in advance.
    >
    > Ravindra
    >
    Bruno Alexandre, Oct 3, 2006
    #2
    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. Ulf Meinhardt
    Replies:
    0
    Views:
    460
    Ulf Meinhardt
    Nov 12, 2005
  2. sindre
    Replies:
    4
    Views:
    3,224
    Toby Inkster
    Sep 27, 2004
  3. =?Utf-8?B?UmF2aW5kcmE=?=
    Replies:
    4
    Views:
    387
    Steve C. Orr [MVP, MCSD]
    Oct 3, 2006
  4. Martin Nadoll

    Form Focus with two Submit-Buttons

    Martin Nadoll, Jan 21, 2004, in forum: Javascript
    Replies:
    1
    Views:
    124
    DJ WIce
    Jan 21, 2004
  5. Roger
    Replies:
    3
    Views:
    322
Loading...

Share This Page