Click here to Skip to main content
13,507,984 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 24 Oct 2011

How to prevent textbox postback when hitting Enter key in ASP.NET

, 24 Oct 2011
Rate this:
Please Sign up or sign in to vote.
This seems to do the job:

This seems to do the job:

<asp:textbox id="tbTest1" runat="server" onkeypress="return event.keyCode != 13;" />


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Generalthis is simple but you wil have to write onkeypress for each... Pin
Ram Balak Sharma13-Dec-11 1:57
memberRam Balak Sharma13-Dec-11 1:57 
Generalprecise and simple 5! Pin
Uday P.Singh5-Nov-11 0:13
memberUday P.Singh5-Nov-11 0:13 
GeneralReason for my vote of 5 Excellent concise answer Pin
tonysawyer2-Nov-11 1:11
membertonysawyer2-Nov-11 1:11 
GeneralReason for my vote of 4 Much simpler than above... thanks f... Pin
BrianBissell1-Nov-11 3:13
memberBrianBissell1-Nov-11 3:13 
GeneralReason for my vote of 5 thanks for tip Pin
beginner201131-Oct-11 15:35
memberbeginner201131-Oct-11 15:35 
GeneralReason for my vote of 5 Short & simple Pin
thatraja26-Oct-11 3:34
mvpthatraja26-Oct-11 3:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180417.1 | Last Updated 24 Oct 2011
Article Copyright 2011 by Steverey42
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid