vb.netbuttonmodal-dialogpostback

Modal button OnClick event not firing in firefox


I have this button inside a modal popup:

<asp:Button runat="server" ID="btnOkay" Text="Invia" OnClick="btnOkay_Click" CssClass="btn btn-danger" UseSubmitBehavior="false" CausesValidation="true" OnClientClick="hideModal('{0}','{1}');" />

This is the "hideModal" function:

<script type="text/javascript">
       function hideModal(sender, e) {
           __doPostBack(sender, e);
       }
   </script>

The problem is this is working fine in Chrome, IE and Edge but not in Firefox (latest). What I can see is that it triggers a page postback before the btnOkay_click event is fired. How can I make it work just like in Chrome? Thanks


Solution

  • Turned out that -for some reason- Firefox fails to execute the OnClientClick event, the solution was to get rid of it and replace it with data-dismiss="modal", so my button is now like this:

    <asp:Button runat="server" ID="btnOkay" Text="Invia" OnClick="btnOkay_Click" CssClass="btn btn-danger" UseSubmitBehavior="false" CausesValidation="true" data-dismiss="modal" />
    

    And it's working fine both on Chrome and Firefox