发生错误时 Jquery 对话框停止关闭?

发布于 2024-09-28 01:37:17 字数 1349 浏览 6 评论 0原文

我在 ASP.NET 中使用 jQuery 对话框。我让它工作正常,除了当我单击对话框中的“确定”按钮时,如果发生错误,我想在标签中显示错误。当对话框关闭事件被触发时已经太晚了。如果发生错误,如何仍然显示该对话框。我不想在出现错误时关闭对话框。

   //setup edit person dialog
     $('#uploadPic').dialog({
             autoOpen: false,
             modal: true,
             height: 375,
             width: 400,    
             draggable: true,
             title: "Upload Picture",
             open: function(type, data) {
                 $(this).parent().appendTo("form");
             }
         });
     }

    function showDialog(id) {
        $('#' + id).dialog("open");
    }

    function closeDialog(id) {
        $('#' + id).dialog("close");
    }

  <input type=button value="Change Image" onclick="javascript:showDialog('uploadPic')" />



<div id='uploadPic'>     
     <asp:FileUpload ID="InputFile"   runat="server" class="ms-fileinput" 
        size="35" />   
     <asp:Button Id="btnOK" runat="server"  Width="70px" Text="<%
    $Resources:wss,multipages_okbutton_text%>" OnClick="btnOK_Click" />
      <asp:Button Id="btnCancel" runat="server" Width="70px"
      CausesValidation="false" Text="Cancel" 
OnClientClick="javascript:closeDialog('uploadPic')" />
            </div>

在后面的代码中,我没有调用任何 JQuery 方法。

I am using the jQuery Dialog in ASP.NET. I have it working fine with the exception of when I click the OK button in the dialog and if an error occurred I want to show the error in the label. By the time the dialog closing event is fired it is too late. How do I still show the dialog if an error has occurred. I don't want to close the dialog when there is an error.

   //setup edit person dialog
     $('#uploadPic').dialog({
             autoOpen: false,
             modal: true,
             height: 375,
             width: 400,    
             draggable: true,
             title: "Upload Picture",
             open: function(type, data) {
                 $(this).parent().appendTo("form");
             }
         });
     }

    function showDialog(id) {
        $('#' + id).dialog("open");
    }

    function closeDialog(id) {
        $('#' + id).dialog("close");
    }

  <input type=button value="Change Image" onclick="javascript:showDialog('uploadPic')" />



<div id='uploadPic'>     
     <asp:FileUpload ID="InputFile"   runat="server" class="ms-fileinput" 
        size="35" />   
     <asp:Button Id="btnOK" runat="server"  Width="70px" Text="<%
    $Resources:wss,multipages_okbutton_text%>" OnClick="btnOK_Click" />
      <asp:Button Id="btnCancel" runat="server" Width="70px"
      CausesValidation="false" Text="Cancel" 
OnClientClick="javascript:closeDialog('uploadPic')" />
            </div>

In code behind I am not calling any JQuery methods.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没有心的人 2024-10-05 01:37:17

问题是您正在表单上使用标准 POST 方法从浏览器窗口上传文件 - 这将导致浏览器导航到新页面。

您可以使用多种技术来允许浏览器上传文件,而无需强制进行页面导航。我建议您查看像 Plupload 这样的库来处理上传。查看他们的演示:

http://plupload.com/example_queuewidget.php

The problem is that you are uploading a file from the browser window using a standard POST method on your form - which will cause the browser to navigate to a new page.

You can use a variety of techniques to allow the browser to upload the file without forcing page navigation to happen. I would recommend looking at a library like Plupload to handle the upload. Check out their demo:

http://plupload.com/example_queuewidget.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文