我使用java脚本Alertify库来使用花哨的警报。但我面临问题,当我想在客户端使用确认框,如果它是真的然后它应该运行服务器端事件。但只是点击按钮它运行服务器端代码..这是代码:请帮我,如果我选择好吧那我应该运行服务器客户端..
<asp:ImageButton id="remove" runat="server"
ToolTip="Delete"
CssClass="controlbuttonjob"
onClientClick="return alertify.confirm('Are you sure you want to Delete?')"
OnClick="remove_click"
ImageAlign="left"
ImageUrl="~/Style/delete.png"
RowIndex='<%# Container.DisplayIndex %>'
/>
答案 0 :(得分:0)
这种类型的对话框会立即运行并立即返回。
稍后,如果您按下某些按钮,例如取消或确定,则会调用您已设置的功能。
确认甚至不返回true或false,返回object of the dialog.
// from the http://fabien-d.github.io/alertify.js/
// confirm dialog
alertify.confirm("Message", function (e) {
if (e) {
// user clicked "ok"
} else {
// user clicked "cancel"
}
});
所以这不像等待用户输入的confirm()
那样工作。
答案 1 :(得分:0)
alertify.confirm("Message", function () {
//clicked OK
return true;
}, function(){
//clicked Cancel
return false;
});