2

I am using masterpage in my solution. In that masterpage there is a imagebutton named "Save" using as the saving option for all my pages, which is set as Defaultbutton in masterpage. The problem is that, in one of my page i have a textchanged event which i want to work when pressing "Enter" key. But when i press "Enter" key "Save" function works after the textchanged event. I dont want to happen "Save" function on "Enter" key press. I don't want there to be any default button on my page

Smile Azeez
  • 147
  • 4
  • 13

2 Answers2

1

I think you have to prevent enter key while you are work in text-box just put this function in ur page.

just add onkeydown event to ur text-box

<input type='text' onkeydown="return (event.keyCode!=13);" />

another one this function need jquery

$('input').keypress(function(event) {
    if (event.keyCode == 13) {
        event.preventDefault();
    }
});
Anant Dabhi
  • 10,864
  • 3
  • 31
  • 49
1

You can set the button's UseSubmitBehavior = "false"

similar question is here Canceling the default submit button in ASP.NET

Community
  • 1
  • 1
Amol Kolekar
  • 2,307
  • 5
  • 30
  • 45