Managing LinkButton with Javascript?

前端 未结 1 1202
庸人自扰
庸人自扰 2021-01-26 05:57

I have a LinkButton called \"Exit Chat\" on the view.I embed javascript code into OnClientClink=javascript:confirm(\'Are you sure you want to end

相关标签:
1条回答
  • 2021-01-26 06:38

    You can check the result of the confirm and then close the window if true.

    <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
            CommandName="Delete" Text="Delete"
            OnClientClick="return showConfirm();">
    </asp:LinkButton>
    
    <script>
    function showConfirm()
    {
       var ok = confirm('Are you certain you want to delete this product?');
    
       if (ok)
       {
          window.close();
       }
    }
    <script>
    
    0 讨论(0)
提交回复
热议问题