Function does not work with Usesubmitbehavior="False"

Asked

Viewed 103 times

1

I own that button:

<asp:Button ID="Button11" runat="server" 
  Text="Cancelar" CssClass="btn btn-danger btn-block" 
  OnClick="Button11_Click" 
  OnClientClick="javascript:return confirm('Deseja cancelar toda a venda?');" 
 UseSubmitBehavior="False" />

I need him to be UseSubmitBehavior="False", but when I put for false, it does not work the confirm, he appears the alert, but whether I click ok, or cancel, it does nothing, when the UseSubmitBehavior="true" it works correctly, but if someone clicks enter, it clicks this button, how can I proceed?

  • You gotta take that UseSubmitBehavior="False" and use another way, what you really want to do?

  • I want that if you click enter anywhere in the form, the click of that button is not done, because this is what is occurring.

  • There’s something wrong with your form Ask him the question!

  • This happens because of Onclientclick="javascript:Return confirm('Want to cancel all sale?');"

1 answer

0


Do so

<asp:Button ID="Button11" runat="server" 
  Text="Cancelar" CssClass="btn btn-danger btn-block" 
  OnClick="Button11_Click" 
  OnClientClick="if ( ! UserDeleteConfirmation()) return false;"  />

function UserDeleteConfirmation() {
  return confirm("Deseja cancelar toda a venda?");
}
  • It worked right, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.