asp.net-mvc – asp.net mvc3 jquery ui对话框和客户端验证
发布时间:2020-05-23 08:02:20 所属栏目:asp.Net 来源:互联网
导读:我在asp.net mvc3应用程序中有客户端验证问题. 我的代码看起来 function loadEditCategoryDialog(categoryId) { $.ajax({ url : /rovastamp3/Admin/CategoryEditDialog, data : categoryId=+categoryId, s
|
我在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ávkov 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 – 如果页面上有异常,则输出缓存无效
- 如何返回404状态,无效参数传递给我的ASP.NET MVC控制器?
- asp.net – 哪些移动浏览器支持javascript(和Ajax)?
- asp.net – CreateUserWizard – 添加步骤,但不要创建用户,
- asp.net-mvc – Visual Studio 2013持有的App_global.asax.
- asp.net – 我的HTML5的doctype是否必须在第一行?
- asp.net-mvc – 与ASP.NET MVC等效的GetWebResourceUrl?
- asp.net下使用jquery 的ajax+WebService+json 实现无刷新取
- ASP.NET MVC 2 – ViewModel前缀
- asp.net-core – 如何在ASP.NET Core中共享汇编信息?
推荐文章
站长推荐
- asp.net-mvc – ASP.NET MVC;使用EditorTemplate
- asp.net – 为什么即使我将EnableViewState设置为
- asp.net – 在jQuery中捕获异常
- asp.net – 为什么removeServerHeader在Azure We
- asp.net – 如何在HTML标记中阅读web.config APP
- asp.net-mvc – Kendo Grid Edit InLine Custom
- asp.net – IItemTransform和现有的缩小文件
- asp.net-mvc – Sitecore和ASP.net MVC
- asp.net-identity – 为什么一个站点的ASP.NET身
- asp.net-mvc – 将依赖项注入自定义模型绑定器并
热点阅读
