All i want is to submit form using jquery and show succesfully added or not messages on screen . Here is the code below. Can anyone provide me help about that ?!
[HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "Id,Template,ShowOnMeny")] Page page) { if (ModelState.IsValid) { db.Pages.Add(page); db.SaveChanges(); return RedirectToAction("Index"); // return Json("Done", JsonRequestBehavior.AllowGet); } // else /// { // return Json("Error"); return View(page); // } }
@model CMSFC.Models.Page@{ ViewBag.Title = "Create"; Layout = "~/Views/Shared/_Layout.cshtml";}<h2>Create</h2> @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>Page</h4> <hr /> @Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div class="form-group"> @Html.LabelFor(model => model.Template, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Template, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Template, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.ShowOnMeny, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> <div class="checkbox"> @Html.EditorFor(model => model.ShowOnMeny) @Html.ValidationMessageFor(model => model.ShowOnMeny, "", new { @class = "text-danger" }) </div> </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="submit" value="Create" class="btn btn-default" /> </div> </div> </div> } <div> @Html.ActionLink("Back to List", "Index") </div>