I have an asp:Panel whose default button is set to Save button of the form. But I want that when the focus is on one specific anchor element in my form, the Enter key should not fire the DefaultButton of Panel. Rather it should fire the Javascript function written inside the href of the anchor, which perfectly works if I just remove the asp:Panel from the form.
I have tried many solutions, but none of them seems to work. Some of them are:-
-
I capture the focus event of anchor in which I hook another handler for keypress event and use
event.preventDefault()so that event is cancelled there only and remove thatkeypressevent on theblurof anchor element. But this does not stop theDefaultButtonof Panel from being executed. -
Use another
asp:Panelinside the outer Panel and set itsDefaultButtonto theImageButtonwhich replaces the anchor element(because we can not setDefaultButtonto anchor). – But this still fires theDefaultButtonof the outside Panel.
What I need is some way to disable the DefaultButton of the outer asp:Panel at the Client Side. Is this possible?
Not quite sure what you are doing, but when you add a DefaultButton attribute to an
asp:Panelthen it adds something like this to the rendered div:You can remove that attribute using jQuery by doing something like:
(Assuming the ClientID of your Panel is
Panel1). Hope that is of some help!