I am working with VB.NET
, I have a GridView
which I define its columns with ItemTemplate
, the thing is that I have a control asp:ImageButton
, for the delete function with an image. The problem is that ASP automatically leaves this Button as submit, that is, if I press the key Enter
, it makes me submit the form and I want to deactivate this.
I know that with the property
UseSubmitBehavior ="false"
for the controls Button
, it disables the submit that it leaves by default, but this property is not usable in ImageButton.
How can I deactivate it, so that pressing Enter does not make a submit of the form?
PS: I don't want to disable the Enter
full form
one, since I need to capture it in a input
certain one.
In the tag
form
you can define through the propertydefaultbutton
which is the button that will act when you pressenter
ASP.NET 2.0 - Enter Key - Default Submit Button
But using javascript you can disable this functionality
How To: Disable Form Submit on Enter Key Press
How To Disable Enter Key On Forms
>>I'm not sure what event to control, since the imagebutton, I can't use the keypress event
If you use jquery you will see that the keypress applies on the tag
form
that is, you cancel the enter (it would be the value 13 that represents it) of the entire form
Another way you could get this behavior is to not use
<asp:ImageButton>
, instead you can use this: