Control Focus Question???

I

inetmug

I have a form with two buttons, and two textboxes. When you are in either
textbox one of the buttons gets focus (blue ring around edges). What is
making the FIRST textbox that was added to the form get the focus? The
second one added does not behave this way.

Also, I noticed that the page.Validate method is also getting fired along
with the TextChanged event when this happens. I have read that the textbox
control itself does not cause validation. jHowever, I clearly see the
page.Validate method firing (because I overrode it to put out some text, and
called the base method).

Thanks
 
I

inetmug

Thanks much Peter.

Peter Blum said:
Within <form> tags, the first <input type='submit'> tag is the default
button with that special formatting. It is used when the user hits ENTER
while focus is not on any button. You cannot change this through HTML. You
must write javascript to capture the onkeypress event, usually on the <body>
or <form> tag, look for the keyCode for ENTER (#13) and call the click
method on the desired button. There are numerous examples on the www.asp.net
forums (search "onkeypress" and "enter") and I'm sure published in articles
on Google.

When a button is clicked, its server side code calls Page.Validate after the
Page_Load method but before calling your Click post back event. If you don't
want that to happen, sets the buttons' CausesValidation property to false.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top