as form.Submit()将在mvc中提交整个。 如果我想在提交如何显示成功或失败。 我不想在临时数据中保持成功状态并将其传递给表格
的方法控制器:
[HttpGet]
public void TestAction()
{
return View()
}
[HttpPost]
public void TestAction(someData)
{
// Store data to DB
return View()
}
Script :
$("#btnSave").click(function(){
form.Submit();
});
答案 0 :(得分:0)
你可以尝试这个http://jameschambers.com/2014/06/day-14-bootstrap-alerts-and-mvc-framework-tempdata/
[HttpPost]
public ActionResult Create(Person person)
{
if (ModelState.IsValid)
{
_people.Add(person);
Success(string.Format("<b>{0}</b> was successfully added to the database.", person.FirstName), true);
return RedirectToAction("Index");
}
Danger("Looks like something went wrong. Please check your form.");
return View(person);
}