当我单击“保存”按钮时,会显示成功警报消息,但我只需要保存功能成功,然后才应显示成功警报消息。
在我的代码中,我在单击按钮时编写了成功警报消息,因此它无法正常工作。如何在成功时在查看包消息中调用 id="bn-success"
。
<input type="submit" name="actionType" id="bn-success" value="Save" class="btn btn-rounded btn-inline btn-success" />
Controller :
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Domain(Domain domain)
{
try
{
int refID = Convert.ToInt32(Session["RefID"]);
if (ModelState.IsValid && refID > 0)
{
userType type = new userType();
int id = type.AddDomain(domain, refID);
if (id != 0)
{
ViewBag.Message = "Domain added successfully";
}
}
return View();
}
catch
{
return View();
}
}
警报消息:
$('#bn-success').on('click', function() {
$.notify({
icon: 'font-icon font-icon-check-circle',
title: '<strong>Heads up!</strong>',
message: @ViewBag.Message
},{
type: 'success'
});
});
最佳答案
'@ViewBag.Message'
$('#bn-success').on('click', function() {
$.notify({
icon: 'font-icon font-icon-check-circle',
title: '<strong>Heads up!</strong>',
message: '@ViewBag.Message'
},{
type: 'success'
});
});
关于javascript - 使用 asp.net mvc 查看包消息在按钮单击成功时无法正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47363657/