5

Possible Duplicate:
ASP.NET Canceling the Default Submit Button

I have only 1 button in my ASP.NET page but when I click "Enter" key the button click function is talking place. I don't want that. Only manual click must work. How to make this?

Community
  • 1
  • 1
Mal
  • 533
  • 1
  • 12
  • 27
  • If the .NET way suggested in the accepted answer of the above question fails, you can use the JS way suggested in [Robert's answer](http://stackoverflow.com/questions/1473388/asp-net-canceling-the-default-submit-button/1473463#1473463) – Shadow The GPT Wizard Sep 26 '11 at 13:25

3 Answers3

33

Set the button's UseSubmitBehavior = "false"

Issa Qandil
  • 1,228
  • 10
  • 17
3
<body onkeypress="return CancelReturnKey();">

  <script type="text/javascript">
        function CancelReturnKey() {
            if (window.event.keyCode == 13)
                return false;
        }
    </script>
Royi Namir
  • 144,742
  • 138
  • 468
  • 792