2
我想表明成功的消息時,插入是complete.Here插入後如何顯示成功消息是我的代碼通過形式提交
[HttpPost]
public ActionResult Create(string txthospitalname, int city)
{
var hospitals = new Hospital()
{
Name = txthospitalname,
FKCityID = city,
CreatedAt = DateTime.Now,
CreatedBy = 1,
};
_db.Hospitals.Add(hospitals);
_db.SaveChanges();
return RedirectToAction("Create");
}
View.cshtml
@using (Html.BeginForm("Create", "Hospital", FormMethod.Post, new {enctype = "multipart/form-data", id = "hospitalform"}))
{
//Text Fields
}
$(文件)。就緒(函數(){ 如果(」 @ ViewBag.Success'==「Added」){ toastr.success(「Hospital added successfull」); } }); –
在腳本中添加此代碼後,它爲我工作就像一個魅力..謝謝親愛的。 –
很高興幫助。 –