jQuery UI 的对话框在 ASP.NET 上不起作用 [英] jQuery UI's Dialog doesn't work on ASP.NET

查看:21
本文介绍了jQuery UI 的对话框在 ASP.NET 上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下测试 ASPX 页面:

<head runat="server"><标题></标题><script src="js/jquery-1.2.6.min.js" type="text/javascript"></script><script src="js/jquery-ui-1.6.custom.min.js" 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="选择内容类型"><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="js/jquery-1.2.6.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui-1.6.custom.min.js" 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="Select content type">
            <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 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆