asp.net-mvc – asp.net mvc3 jquery ui对话框和客户端验证
发布时间:2020-12-15 19:03:38 所属栏目:asp.Net 来源:网络整理
导读:我在asp.net mvc3应用程序中有客户端验证问题. 我的代码看起来 function loadEditCategoryDialog(categoryId) { $.ajax({ url : "/rovastamp3/Admin/CategoryEditDialog",data : "categoryId="+categoryId,success : function(data){ $("#popup_dialog").htm
我在asp.net mvc3应用程序中有客户端验证问题.
我的代码看起来 function loadEditCategoryDialog(categoryId) { $.ajax({ url : "/rovastamp3/Admin/CategoryEditDialog",data : "categoryId="+categoryId,success : function(data){ $("#popup_dialog").html(data); $("#popup_dialog").dialog({ modal: true,draggable: false,resizable: false,title: "Upravit kategorii",width: 600,height: 500,}); } }); } 控制器: [HttpGet] public ActionResult CategoryEditDialog(int categoryId) { CategoryEditViewModel categoryEditViewModel = new CategoryEditViewModel(); categoryEditViewModel.Category = _postAuctionCategoryRepo.Query() .SingleOrDefault(x => x.Id == categoryId); return PartialView(categoryEditViewModel); } [HttpPost] public ActionResult CreateNewCategory(CategoryEditViewModel categoryEditViewModel) { if (ModelState.IsValid) { return RedirectToAction("Index"); } return View("CategoryEditDialog",categoryEditViewModel); } 最后我的部分看法: @model Rovastamp.MVC3.ViewModels.AdminController.CategoryEditViewModel <h2>Upravit kategorii @Model.Category.Name</h2> @{Html.EnableClientValidation();} @using (Html.BeginForm("CreateNewCategory","Admin")) { @Html.ValidationSummary(true) <fieldset> <legend>Objednávkovy formulá?</legend> <div class="editor-label"> @Html.LabelFor(model => model.Category.Name) </div> <div class="editor-field"> @Html.TextBoxFor(model => model.Category.Name) @Html.ValidationMessageFor(model => model.Category.Name) </div> <div class="editor-label"> @Html.LabelFor(model => model.Category.Position) </div> <div class="editor-field"> @Html.TextBoxFor(model => model.Category.Position) @Html.ValidationMessageFor(model => model.Category.Position) </div> <input type="submit" value="Upravit" class="submit_button" /> </fieldset> } 在我的web.config中,我打开了UnobtrusiveJavaScript和ClientValidatin应用程序设置. 如果我在jquery ui对话框上提交按钮,mvc在没有客户端验证的情况下完全刷新? 哪里有问题? 感谢任何帮助 编辑: 在我的布局页面中,我包括这个脚本: > jquery.unobtrusive-ajax.js 编辑2 在我的exemaple我放: jQuery.validator.unobtrusive.parse('#popup_dialog'); 之前我调用jquery ui对话框和客户端验证工作完美. 解决方法
这是因为您正在将PartialView加载到已由jquery.validator.unobstrusive库解析的View中.您需要指示库重新解析页面以考虑您注入的PartialView验证属性.阅读我的
this blog post的这个话题,希望能回答你的问题.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 如何诊断IIS致命通信错误的问题
- asp.net-mvc – 如何在ASP.net控制器操作中访问整个查询字符
- asp.net-mvc – 我能改变MVC中LabelFor渲染的方式吗?
- asp.net-web-api – 如何只获取没有值的Odata.Count
- asp.net-mvc – 哪个更适合为我的网站构建API:MVC或Ado.ne
- asp.net单选按钮分组
- 尽管指定了我自己的视图,ASP.NET MVC3仍然会查找Error.aspx
- 基于B/S模式的asp大学生社团管理系统
- ASP.NET应用程序中的浏览器缓存
- asp.net – 防止加载MicrosoftAjaxWebForms.debug.js
推荐文章
站长推荐
- 有没有办法以编程方式设置ASP.NET Universal Pro
- asp.net-mvc-3 – ASP.NET MVC 3: – 使用数据库
- 为什么ASP.Net服务器控件声明需要runat =“serve
- asp.net-mvc – ASP.NET MVC – Partial View可以
- asp.net-mvc – DAL – > BLL < - GUI组合根.如何
- asp.net – 无法从App.Config中检索密钥
- .net – App_LocalResources如何使用MVC?
- asp.net-web-api – WebApi DelegatingHandler未
- asp.net-mvc – Asp.net MVC – 我可以从不同的视
- asp.net-mvc – MVC项目中的System.Globalizatio
热点阅读