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;
}
};