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

  • Thread starter ravindradonkada
  • 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
 
B

Bruno Alexandre

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"
 

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

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top