Smile Azeez
Smile Azeez

Reputation: 147

DefaultButton when using masterpages ASP.net

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

Upvotes: 2

Views: 811

Answers (2)

Anant Dabhi
Anant Dabhi

Reputation: 11104

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();
    }
});

Upvotes: 1

Amol Kolekar
Amol Kolekar

Reputation: 2325

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

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

Upvotes: 1

Related Questions