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

Responding to Enter keypress event

Status
Not open for further replies.

wbehning

Programmer
Nov 14, 2001
47
US
This may seem like a dumb question, but what causes the command contol's click method to fire when pressing the enter key while on a html text box control.

I have an mobile application, using the Mobile Web Form controls. This form has several HTML Text Field controls. If the Enter key is pressed while one of these controls has the focus, the command contol's Click method runs. I would like to be able to control this, but I am having no luck in figuring this out.

Also, if there are multiple Command controls on a Mobile Web Form, is there a way to control which Command control's Click method fires?
 
i use this javascript...
Code:
function setEnterKey(btnName) {
if (event.keyCode == 13) {
 event.cancelBubble = true;
 event.returnValue = false;
 document.getElementById(btnName).click();
}
}

then this within .NEt to say, when i'm in this textbox, here's what button the Enter key should execute...
Code:
Me.txtSearch.Attributes.Add("onkeypress", "setEnterKey('btnSearch');")

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Another alternative is to use:
Code:
Page.RegisterHiddenField("__EVENTTARGET", "btnSearch")


____________________________________________________________

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