" /> " /> "/>

In asp.net button onclick and onclientclick not working for alert and confirm methods in javascript

561 views Asked by At
<asp:Button ID="btnSubmit" runat="server" style=" float:left"  Text="Submit" `OnClientClick="submitRequest();" onclick="btnSubmit_Click" TabIndex="8"/>`

and

<script type="text/javascript">
function submitRequest() {
            var hdn_YearlyAvailableFund = parseFloat("<%= hdnYearlyAvailableFund.Value %>");

            var hdn_Amount = parseFloat("<%= hdnAmount.Value %>");
            var hdn_QueryString = "<%= hdnQueryString.Value %>";
            var approve = document.getElementById("<%=rdbApprove.ClientID %>");
            var check = approve.checked;
            if (hdn_QueryString.toString() == 'X') {
                if (approve.checked == true) {
                    if (hdn_YearlyAvailableFund < hdn_Amount) {
                        alert('Yearly available fund is less than Requested Amount, Cannot approve...!')                           
                    }
                    else {
                        if (confirm('Are you sure want to update this request?'))
                            document.getElementById('<%= btnSubmit.ClientID  %>').click();
                    }
                }
            }
            else {
                if (confirm('Are you sure want to update this request?')) {
                    document.getElementById('<%= btnSubmit.ClientID  %>').click();
                }
            } 
        }

    </script>

Here in my code for alert and confirm methods are not working together.

i request to give me a solution. Thanks in advance.

1

There are 1 answers

1
wazz On

Try adding the term return; you must return a value:

return confirm('Are you sure want to update this request?')

Also works on OnClientClick.