Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textbox and return 1

Status
Not open for further replies.

HomerJS

Programmer
Jun 25, 2001
86
US
I want a user to enter data into a textbox and then be able to either hit return or click a command button to retrieve the data. The command button works fine, but how do I get it to fire when the user hits the return key when they're still at the textbox?
 
Homer: Good question. Paul(link9)I believe posted the javascript routine for this but haven't seen it in some time (I am also looking for this solution). I believe it is trigger in java as the OnChange event. You might do a search here and at the java forum.
 
It's not javascript, it's just a little different approach to setting up the form.

Declare the button you want to work with &quot;Enter&quot; as a regular old <input type=button> except add the runat=server, an id, and an onServerClick attribute.

Also, you must make the button the first in your form:

<input type=button value=Submit id=btnSubmit runat=server onServerClick=mySubmitRoutineHere>

If you place it as the first button on your form, then it will fire when the user presses &quot;Enter&quot;

-paul
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Thanks for the tip Paul. However I'll throw a wrench into your solution and ask what if the button isn't the first button on the form? Then what can I do to make it fire when a users hits return in the textbox?
 
As far as I have seen there is nothing you can do in this case Homer. If you don't want the button to be positioned as first on the page you can use absolute positioning to accomplish the same thing. You just have to ensure that the button is the first button declared in your rendered html. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Ding ding! Metabuilders with the answer!

thread855-288280

I put the link to the page in our TidBits thread. It's at the bottom.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
nice find paul That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top