How to disable Enter key pressed inside TextBox to avoid submission or postback in Asp.Net?

 Posted by vishalneeraj-24503 on 7/8/2014 | Category: ASP.NET Interview questions | Views: 1722 | Points: 40
Answer:

In textbox definition,we have to write below code on onkeydown event as:-
<asp:TextBox ID="txt_emp_first_name" runat="server" onkeydown = "return(event.keyCode!=13);"></asp:TextBox>

Here,13 is keyboard Enter button key code.
When enter key is pressed the above condition is false hence false is returned therefore the postback will be disabled.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response