ASP.NET MVC 4 AJAX提交表单不工作
发布时间:2020-12-15 23:48:15 所属栏目:asp.Net 来源:网络整理
导读:我试图使用MVC 4中的Ajax.BeginForm帮助方法将窗体从同步转换为异步. 在我看来,我有: @{ ViewBag.Title = "Users Edit"; var options = new AjaxOptions() { Url = Url.Action("Edit","User"),LoadingElementId = "saving",LoadingElementDuration = 2000,C
我试图使用MVC 4中的Ajax.BeginForm帮助方法将窗体从同步转换为异步.
在我看来,我有: @{ ViewBag.Title = "Users > Edit"; var options = new AjaxOptions() { Url = Url.Action("Edit","User"),LoadingElementId = "saving",LoadingElementDuration = 2000,Confirm = "Are you sure you want to save this User?" }; } <div id="saving" style="display:none; color:Red; font-weight: bold"> <p>Saving...</p> </div> @using (Ajax.BeginForm(options)) { @Html.ValidationSummary(true) <fieldset> .... FIELDS ... <p> <input type="submit" value="Save" /> </p> </fieldset> } 当点击提交按钮时,正在执行完整的回发.我的动作方法如下所示: [HttpPost] public ActionResult Edit(User user) { if (ModelState.IsValid) { _repository.Save(user); TempData["message"] = String.Format("{0} has been saved.",user.Username); } return View(user); } 有没有我失踪的东西? MVC 4目前的版本有几个问题吗? 在我的Web.Config我确实有ClientValidationEnabled和UnobtrusiveJavaScriptEnabled设置为true. 我也在我的_Layout.cshtml中指定了这些: <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> 解决方法
也许你错过了不引人注意的ajax脚本: <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 设置debug =“false”时出现“请求超时.”错误
- 如何为ASP.NET应用程序全局设置autocomplete = off?
- 如何配置IIS 7以使用子目录作为默认文档?
- asp.net-mvc-3 – Elmah和ASP.NET MVC 3
- 如何使用asp.net向多个收件人发送电子邮件?
- asp.net – 简单LINQ和列表错误:WhereListIterator`1 [任务
- asp.net-mvc – HTML提交按钮与基于AJAX的Post(ASP.NET MVC
- asp.net mvc ajax上传解决方案?
- asp.net – 构建成功,但发布失败
- asp.net-mvc – 用于MVC网格的Kendo UI如何隐藏ID列
推荐文章
站长推荐
热点阅读