
[英]How to open a dialog box after submit a form to show posted successfully - asp.net MVC
[英]How to popup dialog after form gets submitted in ASP.NET MVC?
我正在做一个表单提交并使用 jQuery 显示弹出对话框。
我参考以下链接并修改了我的代码:-
http://www.primaryobjects.com/2012/03/21/creating-a-jquery-modal-confirmation-dialog-when-submitting-a-form/
它用于确认并通知数据是否不正确或为空,但现在我还想在表单数据保存到另一个视图中的 jqgrid 后显示对话框
$(document).ready(function () {
// Confirmation Dialog
$('#confirmDialog').dialog({
autoOpen: false,
width: 500,
modal: true,
resizable: false,
buttons: {
"Yes": function () {
$(".ui-dialog-buttonpane button:contains('Submit')").button("disable");
document.contactForm.submit();
}
}
});
// Information Dialog
$('#informDialog').dialog({
autoOpen: false,
width: 500,
modal: true,
resizable: false,
buttons: {
"OK": function () {
$(this).dialog("close");
}
}
});
/* After Form Submit Dialog (I want this dialog to open after I submit form and the page
reloads then this should popup) */
$('#finalSavedDialog').dialog({
autoOpen: false,
width: 500,
modal: true,
resizable: false,
buttons: {
"OK": function () {
$(this).dialog("close");
}
}
});
$('#uploadForm').submit(function (e) {
e.preventDefault();
if(($("#file").val()=="")){
$('#informDialog').text("Please upload file");
$('#informDialog').dialog('open');
}
else if(($("#Name").val()=="")){
$('#informDialog').text("Please enter name");
$('#informDialog').dialog('open');
}
else if(($("#Age").val()=="")){
$('#informDialog').text("Please enter age");
$('#informDialog').dialog('open');
}
else{
$('#confirmDialog').dialog('open');
}
});
});
@using (Html.BeginForm("UserDetails","UploadUserDetails", FormMethod.Post, new {enctype = "multipart/form-data", id = "uploadForm", name = "uploadForm"}))
{
<div class="uploadform-title"><h1>Upload Details</h1></div>
<div class="main">
<div class="user-details">
<div class="input-box">
<span class="details">Name</span>
<input type="text">
</div>
<div class="input-box">
<span class="details">Age</span>
<input type="text">
</div>
<div class="input-box">
<span class="details">Upload Pdf File</span>
<input type="file">
</div>
</div>
<div class="button">
<input type="submit" id= "btnSubmit" value="Save">
</div>
</div>
}
/*Below is the Html Code for popup dialog boxes*/
<div id="confirmDialog" title="Confirmation">
<h2>Do you want to submit the form?</h2>
</div>
<div id="informDialog" title="Information">
<h2>Please enter all the feilds</h2>
</div>
<div id="finalSavedDialog" title="Success">
<h2>Saved succefully</h2>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.