【发布时间】:2021-11-05 05:16:52
【问题描述】:
我想在我的应用程序上显示成功自定义警报。 我从另一个线程中得到了一些答案。我已经这样应用了。控制器
public ActionResult Create([Bind(Include = "Id,SuppName,Pay_Method,Status,Create_By,Create_Date")] M_Supplier m_Supplier)
{
if (ModelState.IsValid)
{
m_Supplier.Create_By= int.Parse(((System.Security.Claims.ClaimsIdentity)User.Identity).FindFirst("UserId").Value);
m_Supplier.Status = true;
m_Supplier.Create_Date = DateTime.Now;
db.M_Supplier.Add(m_Supplier);
db.SaveChanges();
return RedirectToAction("Index", new { ac = "success" });
}
return View(m_Supplier);
}
还有风景
@Html.ActionLink("Back to List", "Index")
@{
var parameter = Request.QueryString["ac"];
//Check parameter here and display Message
if (parameter == "success")
{
<div class="alert alert-success alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Record Added Successfully.</strong>
</div>
}
}
我担心的是,当再次定向到索引时,它会显示成功消息。如何在创建视图中显示它然后定向到索引视图?
【问题讨论】:
标签: javascript asp.net asp.net-mvc asp.net-mvc-4