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
Asked
Active
Viewed 808 times
2
-
Not sure, do you want to remove the default button for that particular page ? – V4Vendetta Sep 18 '12 at 05:29
-
@V4Vendetta :- yes. I want to remove defaultbutton for that particular page – Smile Azeez Sep 18 '12 at 05:31
-
1Ok, Maybe you can do something like `this.Form.DefaultButton = null` on page load – V4Vendetta Sep 18 '12 at 05:33
-
@V4Vendetta :- i tried, but now textchanged event is not working when pressing "Enter" key. – Smile Azeez Sep 18 '12 at 08:44
2 Answers
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