This is a rather annoying situation with a simple solution. Your page contains a textbox and if you press the enter key while the textbox has focus, it will trigger a POST request to the server. Unfortunately for the user, it’s pure habit to do this – you type in something and immediately hit Enter while the textbox still has focus. The Google home page is a classic example.
The trick to stop this happening is to catch the textbox’s key down event and either ignore or perform some other action. So the first thing to do is assign a key-down handler to the textbox in your page markup. In this example I’m using an HTML
input control but it works exactly the same way for an ASP.NET TextBox server control (because the resulting markup sent to the client is still effectively the same).
When the event handler returns false, the automatic POST request caused by the key down event is simply cancelled.