amit shukla

amit shukla

  • NA
  • 78
  • 66.7k

Handle enter key press with two button.

Oct 25 2016 3:20 AM
hello friends
Today i am facing a problem given below.
 
in asp.net page , we take two button and one textbox on a asp.net page.
we want to manage enter key press on textbox , but when we press enter key on textbox
then automatically another button click event is call and textbox key up event is not call .
so please help this.
example :
 
<asp:TextBox ID="txtProjectName" runat="server" placeholder="Project Number"></asp:TextBox>
 
<asp:Button runat="server" ID="btnSerach" OnClientClick="return vallidateFields();" OnClick="btnSerach_Click" />
 
<asp:Button ID="txtY" class="btn blue" Text="Yes"  runat="server" OnClientClick="return vallidatePopUpFields();" OnClick="txtY_Click" /> 
 
when we press enter on textbox then call button click event but we want to call below code
 
$('#<%=txtProjectName.ClientID%>').keyup(function (e) {
debugger
if(e.keyCode == 13)
{
     $('#<%=btnSerach.ClientID%>').click();
}
});
 

Answers (3)