发生错误时 Jquery 对话框停止关闭?
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您正在表单上使用标准 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