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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Key

Status
Not open for further replies.

Ramo83

Programmer
Apr 7, 2005
20
IE
How can I assign the "return" key to a specific button in the form? Im making a search engine and I want to press "enter" to make the search instead of clicking the search button...
Thank you
 
On your form theres a Property called Accept Button. Set its value to the Button you want performed when pressing return.
 
set the AcceptButton property of the form to point at the button you want to be activated by the enter key.

similarly, the CancelButton property will associate a button with the escape key.

regards,

mr s. <;)

 
Ok the problem that WebForm does not contain a definition for 'AcceptButton' property...
Thanx,
Ramo
 
Note that it's a form for a web application not a windows application..
Thanx,
Ramo
 
In that case there are two options:

1) You should be able to use the RegisterHiddenField method e.g.
Code:
this.RegisterHiddenField("__EVENTTARGET", "btnSearch");

2) Use a javascript function. e.g.



--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Actually I'm not that familiar with the RegisterHiddenField method... Any details please??
Regards,
Ramo
 
Ramo83 - Why not try it and see what happens?

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Okay but what is the problem I just wanted to know more about the RegisterHiddenField method...
 
Have a look at the help files that come with Visual Studio (if you don't have them they can be viewed at
--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top