【发布时间】:2012-02-12 17:39:27
【问题描述】:
我正在使用 JQuery UI 对话的 asp.net 页面。此对话框有一个提交按钮。当我单击提交按钮时,对话框关闭。我想在它上面调用一个Webmethod。如果方法返回 ture,那么我想关闭它,否则我想保持打开状态并显示错误消息。
[已编辑]
<script>
jQuery(function () {
var dlg = jQuery("#dialog").dialog({
draggable: true,
resizable: true,
show: 'Transfer',
hide: 'Transfer',
width: 320,
autoOpen: false,
minHeight: 10,
minwidth: 10,
beforeClose: function () {
$.ajax({
url: "Default.aspx/GetResult",
success: function (response) {
if (response == true) {
("#dialog").close()
}
else {
alert('asdasdds');
}
}
});
return false; //this will stop dialog box to close
}
});
dlg.parent().appendTo(jQuery("form:first"));
});
</script>
<div id="Result">
Click here for the time.</div>
<div id="dialog" style="text-align: left; display: none;">
<asp:Button ID="btnButton" runat="server" Text="Button" OnClick="btnButton_Click" />
</div>
怎么做。请提出建议。
问候, 阿西夫·哈米德
【问题讨论】: