asp.net button works in the second click

0

I have the following problem, I have a button in asp.net which does an action correctly, I have also created a function in javascript to show a confirmation message.

The problem occurs because the button only works when it is pressed a second time.

<script type="text/javascript">
    $(function mensaje() {
        var btn = $('#<%=btn_distribuir.ClientID %>').attr('name');
        abcbpo.ConfigConfirmacion('confirmacion', 'spanConfirmacion', '¿Estás seguro registrar la operación?', btn);});
</script>

<asp:Button ID="btn_distribuir" runat="server" OnClientClick="$('#confirmacion').dialog('open'); return false;" Text="Confirmar Distribución Facturas" Width="250px" />
    
asked by Wazup2710 26.08.2016 в 07:30
source

1 answer

1

in the OnClientClick I see that you define a .dialog('open'); , but I do not see that at any time you invoke the function mensaje() ?

<script type="text/javascript">
    function mensaje(ctrl) 
    {
        //$('#confirmacion').dialog('open');

        var btn = $(ctrl).attr('name');
        abcbpo.ConfigConfirmacion('confirmacion', 'spanConfirmacion', '¿Estás seguro registrar la operación?', btn);}

        return false;
    }
</script>

<asp:Button ID="btn_distribuir" runat="server" OnClientClick="return mensaje(this);" Text="Confirmar Distribución Facturas" Width="250px" />

As you will see the function is not defined within $ () of jquery there are only attached events What was not clear is that it would be this abcbpo.ConfigConfirmacion() but imagine that after accepting the dialogue would make the post of the button, but remember that if you use the .dialog('open'); you will have to use __dopostBack() to launch the button event from javascript

    
answered by 26.08.2016 в 13:17