Monday, October 24, 2005

Shortcut Keys for enter in Javascript + ASP.net


  1. SCRIPT LANGUAGE="javascript"
  2. function testEnterKey()
  3. {
  4. if (event.keyCode == 13)
  5. {
  6. event.cancelBubble = true;
  7. event.returnValue = false;
  8. Main.btnSearch.click();
  9. }
  10. }
  11. /SCRIPT
*Add the <> tags for the script

Then put this in your page load of the aspx.vb

txtSearch.Attributes.Add("onkeypress", "testEnterKey();")

http://www.faqts.com/knowledge_base/view.phtml/aid/8170