How To Call Click Event On A Button When Retern Is Pressed On A TextField In The Codebehind



TODO:

Have you ever wanted to "click" a button when someone presses return on a Textbox?  The code below, goes in the codebehind of your aspx file.

 

SOLUTION:

myTextBox.Attributes.Add("onkeypress", "if(event.keyCode==13) {document.getElementById('" + myButton.ClientID + "').click(); return false;}");

 

NOTES:

There are no notes on this topic.



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading