jQuery UI#39;s Dialog doesn#39;t work on ASP.NET(jQuery UI 的对话框在 ASP.NET 上不起作用)
问题描述
我有以下测试 ASPX 页面:
<head runat="server"><标题></标题><script src="anMvanF1ZXJ5LTEuMi42Lm1pbi5qcw==" type="text/javascript"></script><script src="anMvanF1ZXJ5LXVpLTEuNi5jdXN0b20ubWluLmpz" type="text/javascript"></script><脚本类型="文本/javascript">$(函数(){var dlg = $("#dialog").dialog({bgiframe:是的,自动打开:假,身高:300,模态:真,纽扣: {'好的':函数(){__doPostBack('TreeNew', '');$(this).dialog('close');},取消:函数(){$(this).dialog('close');}},关闭:函数(){dlg.parent().appendTo(jQuery('form:first'));}});});函数显示对话框(){$('#dialog').dialog('open');}</脚本></头><身体><form id="form1" runat="server"><asp:Button ID="TreeNew" runat="server" Text="New"OnClientClick="ShowDialog();return false;"onclick="TreeNew_Click"/><asp:Label ID="Message" runat="server"></asp:Label><div id="dialog" title="6YCJ5oup5YaF5a6557G75Z6L"><p id="validateTips">所有表单字段都是必需的.</p><asp:RadioButtonList ID="ContentTypeList" runat="server"><asp:ListItem Value="1">Texte</asp:ListItem><asp:ListItem Value="2">图片</asp:ListItem><asp:ListItem Value="3">音频</asp:ListItem><asp:ListItem Value="4">视频</asp:ListItem></asp:RadioButtonList></div></div></表格></身体></html>我在 close function 上使用 dlg.parent().appendTo(jQuery('form:first'));
从 RadioButtonList.
它运行良好,但在页面执行 PostBack 之前,div对话框"移动到新建按钮下方.为什么?
解决方案 我认为这是因为你在调用:
dlg.parent().appendTo(jQuery('form:first'));
在关闭回调时.这将移动对话框.为什么不在创建对话框后立即调用它?
I have the following test ASPX page:
<head runat="server">
<title></title>
<script src="anMvanF1ZXJ5LTEuMi42Lm1pbi5qcw==" type="text/javascript"></script>
<script src="anMvanF1ZXJ5LXVpLTEuNi5jdXN0b20ubWluLmpz" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var dlg = $("#dialog").dialog({
bgiframe: true,
autoOpen: false,
height: 300,
modal: true,
buttons: {
'Ok': function() {
__doPostBack('TreeNew', '');
$(this).dialog('close');
},
Cancel: function() {
$(this).dialog('close');
}
},
close: function() {
dlg.parent().appendTo(jQuery('form:first'));
}
});
});
function ShowDialog() {
$('#dialog').dialog('open');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="TreeNew" runat="server" Text="New"
OnClientClick="ShowDialog();return false;" onclick="TreeNew_Click"/>
<asp:Label ID="Message" runat="server"></asp:Label>
<div id="dialog" title="U2VsZWN0IGNvbnRlbnQgdHlwZQ==">
<p id="validateTips">All form fields are required.</p>
<asp:RadioButtonList ID="ContentTypeList" runat="server">
<asp:ListItem Value="1">Texte</asp:ListItem>
<asp:ListItem Value="2">Image</asp:ListItem>
<asp:ListItem Value="3">Audio</asp:ListItem>
<asp:ListItem Value="4">Video</asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
</form>
</body>
</html>
I use dlg.parent().appendTo(jQuery('form:first'));
on close function to retreive the values from RadioButtonList.
It works well but before the page do the PostBack the div "Dialog" moves below the New button. Why?
解决方案 I think that this is caused because you are calling:
dlg.parent().appendTo(jQuery('form:first'));
at the close callback. This will move the dialog. Why don't you call this immediately after creating the dialog?
这篇关于jQuery UI 的对话框在 ASP.NET 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery UI 的对话框在 ASP.NET 上不起作用


- C#MongoDB使用Builders查找派生对象 2022-09-04
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01