Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jqueryui';s对话框没有';我不能在ASP.NET上工作_C#_Asp.net_Jquery Ui_Modal Dialog - Fatal编程技术网

C# jqueryui';s对话框没有';我不能在ASP.NET上工作

C# jqueryui';s对话框没有';我不能在ASP.NET上工作,c#,asp.net,jquery-ui,modal-dialog,C#,Asp.net,Jquery Ui,Modal Dialog,我有以下测试ASPX页面: <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&

我有以下测试ASPX页面:

<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>

$(函数(){
var dlg=$(“#dialog”).dialog({
bgiframe:是的,
自动打开:错误,
身高:300,
莫代尔:是的,
按钮:{
“确定”:函数(){
__doPostBack('TreeNew','');
$(this.dialog('close');
},
取消:函数(){
$(this.dialog('close');
}
},
关闭:函数(){
parent().appendTo(jQuery('form:first');
}
});
});
函数ShowDialog(){
$('dialog')。dialog('open');
}

所有表单字段都是必需的

戴克斯特 形象 音频 视频
我使用
dlg.parent().appendTo(jQuery('form:first')打开关闭功能,从RadioButtonList检索值

它工作得很好,但是在页面回发之前,div“Dialog”会移动到New按钮下面。为什么?

试试换衣服 $(函数(){ 到 $(文档).ready(函数(){


还可以使用某种javascript调试器opera Get builtin和FireFox Get FireBug检查失败的地方。

我认为这是因为您正在调用:

dlg.parent().appendTo(jQuery('form:first'));

在关闭回调时。这将移动对话框。为什么不在创建对话框后立即调用它?

,因为如果我在创建对话框后立即调用它,我会一直看到对话框。如果您已将autoOpen设置为false(如您所做),则不应看到对话框。您应该调用$(“#dialog”).dialog()然后调用dlg.parent().appendTo。如果对话框始终处于打开状态,请检查所有js和css文件是否都正确包含。我发现了问题。这是关于jQuery的版本。正如您在问题中看到的,我一直在使用jQuery-1.2.6.min.js和jQuery-ui-1.6.custom.min.js。我已更改为jQuery-1.3.2.min.js和jQuery-ui-1.7.2.custom.min.js,并且还添加了一个打开的窗口对话框上的操作:open:function(type,data){$(this).parent().appendTo(“form”);}并且它可以工作!!!如果我指定modal=true,“modal”div被画在表单标签的外面,在Internet Explorer上,两个滚动条都会不断变大。在Firefox上,两个滚动条都会出现,但它们不会长大。