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

  • Thread starter Thread starter ravindradonkada
  • Start date Start date
R

ravindradonkada

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
 
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"
 
Back
Top