gpt4 book ai didi

javascript - 在 usercontrol 页面上打开时,jquery 对话框没有关闭

转载 作者:可可西里 更新时间:2023-11-01 02:46:13 25 4
gpt4 key购买 nike

我使用了 jQuery 对话框。父级具有用户控件,该控件具有单击时打开弹出页面的图像。 aspx 页面有取消按钮来关闭 jquery 方法,它是有效的。我在父页面上添加了我的 jquery 文件。我将对话框 div 放在父页面上。

问题在于关闭 jquery 对话框并重新加载父项。如果我在弹出页面的标题上添加我的 jquery 文件,将调用该函数,但错误是:

JavaScript runtime error: Object doesn't support property or method 'dialog'. Also the Cancel button didn't close the jquery.

但是,当我在弹出页面上取消注释我的 jquery 文件时,取消按钮起作用。但是另一个关闭弹出窗口并重新加载父页面的按钮,没有调用jquery方法,弹出页面重新加载并没有关闭。

jQuery中有我的代码

function openmodel(url, name, width, height) {
var maxHeight = dialogMaxHeight(height);
var dialogHeight = height;
if (height > maxHeight)
dialogHeight = maxHeight;

$('#dialog-model').dialog({
my: "center",
at: "center",
of: window,
autoOpen: false,
resizable: true,
max_height:'auto',
height: 'auto',
width: width,
title: name,
modal: true,
draggable: true,
open: function( ) {
$(this).load(url);
},
});

$('#dialog-model').dialog('open');
return false;
}

function CloseDialogmodel() {
$('#dialog-model').dialog({
autoOpen: false,
resizable: true,
title: name,
modal: true,
});

$('#dialog-model').dialog('close');
}


function CloseDialogModelAndReloadParent() {
CloseDialogmodel(); }

aspx页面隐藏代码:

 Private Sub btnDone_Click(sender As Object, e As EventArgs) Handles btnDone.Click
'do something on server
Dim cs As ClientScriptManager = Page.ClientScript
cs.RegisterStartupScript(Page.GetType (), "closeandload", "CloseDialogBoxAndReloadParent();", True)
End Sub

希望有人告诉我如何解决这个问题,这样我就可以关闭弹出页面并重新加载它。提前致谢。

最佳答案

我有同样的问题,我是这样处理的:

Child.aspx-标记

<div class="button">   
<asp:Button ID="btnDone" Text="Done" runat="server" />

<a ID="lnkClose" onclick="DecideForParent(false,true);return false;">
Close
</a>
</div>

<script type="text/javascript">
function DecideForParent(AllowReferesh, AllowClose) {
try {
if (AllowReferesh)
window.opener.HandlePopupResult();
}
catch (ex) {
}
// Close dialog
if (AllowClose)
$('#dialog-model').dialog('close');
}
</script>

Child.aspx-代码隐藏(C#)

private void btnDone_Click(object sender, EventArgs e) 
{
// Do something ...
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallreturnToParent", "$(window).load(function () { DecideForParent(true,true);return false;});", true);
}

Parent.aspx-标记

<script type="text/javascript">
function HandlePopupResultLURow() {
document.getElementById('<%=btnRefresh.ClientID%>').click();
}
</script>

Parent.aspx-代码隐藏(C#)

private void btnRefresh_Click(object sender, EventArgs e) 
{
// Refresh your data
}

关于javascript - 在 usercontrol 页面上打开时,jquery 对话框没有关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50428954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com