1. 程式人生 > >aspx中的asp:LinkButton控制元件在js呼叫不觸發後臺處理程式

aspx中的asp:LinkButton控制元件在js呼叫不觸發後臺處理程式

 var conswich = '0';
        function clientConfirm(thisbutton) {
            var payment =  $('#<%=RealPayment.ClientID%>');
            console.log('conswich val is ' + conswich);
            if (conswich == '0') {
                event.preventDefault();
                payment.val('');
                layer.prompt({ title: '請輸入需要付款的金額', formType: 0 }, function (pass, index) {


                    if (!pass) {
                        layer.msg('請輸入金額');
                        return false;
                    };
                    var checkNum = /^\d+(\.\d{1,2})?$/;
                    if (checkNum.test(pass)) {
                        if (pass > $(thisbutton).parents('tr').find('td:eq(6)').html().trim() * 1) {
                            layer.msg('金額過大');
                        } else {
                            payment.val(pass);
                            layer.close(index);
                            conswich = '1';
                            console.log('thisbutton id is ' + $(thisbutton).attr('id').replace(/_/g, '$'));
                            __doPostBack($(thisbutton).attr('id').replace(/_/g, '$'), '');
                        }
                    } else {
                        layer.msg('金額格式不正確');
                    };
                });
                return false;
            } else {
                conswich = '0';
                console.log('payment val is '+payment.val());
                return true;
            }
        };