asp:LinkButton控件的後臺觸發命令是href="javascript:__doPostBack('ctl00$cphMain$RepOrder$ctl05$btnConfirm','')。我一直認爲它像普通的a標籤一下,使用$('id').trigger('click')去再次觸發。結果總不會被後臺處理。原來asp:LinkButton控件的後臺調用是js的doPostBack去處理的。是CommandName命令去做的。類似在asp的repeater中都是使用這個命令去處理的。這個問題困擾了我半天的時候。現在終於找到原因了。特此記錄在這裏。如果有在被這個問題困擾的人,能給予一定的幫助。
貼上當時的處理代碼
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;
}
};