gpt4 book ai didi

c# - 当 scriptmanager 调用 jquery 对话框时页面消失

转载 作者:太空宇宙 更新时间:2023-11-03 20:39:40 24 4
gpt4 key购买 nike

我的 Asp.net 应用程序出现问题。当我尝试保存一些数据时,我检查数据是否正确,如果不正确,我调用带有错误消息的 jquery 对话框。但是当我的 jquery 对话框出现时,我的背景表单消失了。我收到一个 javascript 错误:“html 解析错误无法在子元素关闭之前修改父容器元素”。

这是我在代码隐藏中的 jquery 对话框调用:

    string script = "openDialog('" + text + "', '" + title + "');";
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "open", script, true);

这是我母版页中的 jquery 对话框:

    function openDialog(text, title) {
var $dialog = $('<div></div>')
.html(text)
.dialog({
autoOpen: false,
title: title,
modal: true,
height: 100,
width: 220,
buttons: {
Ok: function() {
$(this).dialog('close');
}
},
open: function(event, ui){
$('body').css('overflow','hidden');
}
});

$dialog.dialog('open');
}

我在某些页面上使用了相同的代码并且可以正常工作?

最佳答案

哇!我刚刚意识到对话框的标记在 <form> 内标签,将其移出,现在可以使用了。好像 VS 扩展了 <form>当我添加一些东西并将我的东西也抓进去时。

<div id="dialog-form" title="Fill Here">

<fieldset>

<textarea rows="10" id="myPaste" cols="50"></textarea>

</fieldset>
</div>
<button id="create-user">Click Here</button>

<asp:Button ID="btnSend" runat="server" Text="Send ALL"
onclick="btnSend_Click" Width="127px" />
</form>

改为:

 <asp:Button ID="btnSend" runat="server" Text="Send ALL" 
onclick="btnSend_Click" Width="127px" />
</form>

<div id="dialog-form" title="Fill Here">

<fieldset>

<textarea rows="10" id="myPaste" cols="50"></textarea>

</fieldset>
</div>

<button id="create-user">Click Here</button>

关于c# - 当 scriptmanager 调用 jquery 对话框时页面消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3633527/

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