asp.net-mvc - 如何在 Form Post 返回 RedirectToAction 之前使用 SweetAlert?
问题描述
模型
public class Company{
[StringLength(30)]
public string Name{ get; set; }
[StringLength(15)]
public string RegisterNo { get; set; }
}
看法
<form id="form" method="post" action="/Controller/Save" style="font-size:13px;">
<div class="row pb-3">
<div class="form-row">
<div class="col-md-3">
<div class="position-relative form-group">
<label class="">Company Name</label> @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control", @maxlength = "30" } })
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-6">
<div class="position-relative form-group">
<label class="">Reg No</label> @Html.EditorFor(model => model.RegisterNo, new { htmlAttributes = new { @class = "form-control", @maxlength = "15" } })
</div>
</div>
</div>
</div>
</form>
<button name="submit">Save</button>
控制器
public ActionResult Save(Company CompDet){
string Name = CompDet.Name;
string RegNo = CompDet.RegisterNo;
//then Connect DB and Save DB
//HOW TO use SweetAlert before, return RedirectToAction
}
我目前正在使用,return RedirectToAction
仅。
如何在 RedirectToAction 之前添加 SweetAlert?
使用 Ajax Post 还是 Form Post?
可以同时使用 Ajax 和 Form Post 吗?
保存后 -> 显示 Sweetalert 成功 -> 返回 redirectToAction
我还处于学习阶段。请帮忙。
谢谢你
解决方案
推荐阅读
- python - 如何按标签解析快速修复传入消息?
- mysql - 我在安装过程中没有设置 Mysql 的 Root 密码的选项
- visual-studio-code - 为什么 VS Code 上下文菜单显示单个项目
- mysql - MySQL获取不同时区的午夜数据
- javascript - jQuery:嵌套字母变换函数
- git - 如何重新编写 Git 存储库中的所有提交?
- powershell - 无法使用批处理文件运行 PowerShell 脚本
- java - Apriori 的 HashSet 中的空指针异常
- excel - 如何使用多个分隔符拆分字符串并在vba excel中加入部分?
- html - 静态站点的 URL