views:

41

answers:

3

Hi

I'm designing a website and I want my login page to catch "Enter" with all components, but i can not assign any Key or Mouse Events to TextBox ... After pressing to "Enter" a function should be run with 2 parameters (user name and password).

How can i do this?

A: 

If you wrap all the controls inside a standard HTML form then hitting enter in one of the text boxes will submit the form. You can then process the username and password entered on the server as with a normal form submission. Is that the behaviour you're looking for?

You don't need to trap any events on the client in this case so no need for JavaScript.

HullCitySteve
A: 

How to submit ASP.NET forms with the enter key

Read up on the defaultbutton property for forms and panels. This should get you what you want. From the site above:

ASP.NET 2.0 introduces a wonderful work around for this. By simply specifying the "defaultbutton" property to the ID of the , whose event you want to fire, your job is done. The defaultbutton property can be specified at the Form level in the form tag as well as at panel level in the definition tag. The form level setting is overridden when specified at the panel level, for those controls that are inside the panel.

Tommy
the web site is not for TextBox, it is for buttons ...
softwaremonster
A: 

http://www.beansoftware.com/asp.net-tutorials/accept-enter-key.aspx

finally if found the answer. Here is ! The only problem is, I can not hide my button, so that i put that button to web page as "Login" ... Defaultbutton could be hidden or not?

softwaremonster