I have the following asp.net textbox control.
<asp:TextBox ID="txtAdd" runat="server" />
After the user writes something in this textbox and presses the ENTER key, I want to run some code from codebehind.
What should I do?
Using jQuery I captured ENTER key and fired some hidden button event
$(document).ready(function(){
$(window).keydown(function(e){
if(e.keyCode == 13) $('#<% addbtn.ClientID %>'.click();
});
});
Is there any better way ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…