Disable Enter key to avoid postback

Textbox below is the one that does not do a postback when enter key is pressed inside it
<asp:TextBox ID="TextBox1" runat="server" onkeydown = "return (event.keyCode!=13);" ></asp:TextBox>
Or set it in VB.Net
TextBox1.Attributes.Add("onkeydown", "return (event.keyCode!=13);")

In order to disable the enter key form submission on all controls simply add it to the body tag in the following way
<body onkeydown = "return (event.keyCode!=13)">

No comments:

Post a Comment