0
我想實現一些jQuery UI對話框,但我找不到任何我想做的事情的好例子。我正在使用MVC4和CRUD。一旦我創建了一個記錄,我想要顯示一個jQuery對話框來告訴用戶這已完成,與編輯相同。任何示例或教程讚賞。使用MVC和CRUD的jQuery UI對話框
一旦這個帖子被稱爲db.savechanges()已經成功,然後重定向通知用戶,這將是很好的一個jQuery對話框。
一個簡單的例子,我做了什麼。
這是我的看法
@model Models.customer
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>customer</legend>
@Html.EditorForModel()
</fieldset>
<div id="submitCreateButton">
<input type="submit" value="Create" />
</div>
}
<div id="backToListLink">
@Html.ActionLink("Back to List", "Index",new { conName = ViewBag.connectionName }, null)
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
和我的控制器
[HttpPost]
public ActionResult Create(customer customer)
{
using (db = new trakman_Entities(staticConnection))
{
if (ModelState.IsValid)
{
customer.code = customer.code.ToUpper();
db.customers.AddObject(customer);
db.SaveChanges();
return RedirectToAction("Index");
}
}
return View(customer);
}