1
我的工作,我已經使用JQuery用戶界面對話的asp.net頁面上。這個對話框有一個提交按鈕。當我點擊提交按鈕對話框關閉。我想調用一個Web方法。如果方法返回ture,那麼我想關閉它,否則我想保持它打開並顯示錯誤消息。asp.net提交按鈕關閉jQuery的阿賈克斯
[編輯]
<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>
如何做到這一點。請建議。
問候, 阿西夫·哈米德
感謝您的快速反應。如何與jQuery UI的對話框使用此代碼? – DotnetSparrow 2012-02-12 17:53:36
當您點擊提交或關閉按鈕關閉對話框時,您必須基本執行此代碼。代碼關閉對話框在哪裏? – ShankarSangoli 2012-02-12 17:55:32
請更新的問題。我已經添加了代碼 – DotnetSparrow 2012-02-12 18:06:17