asp.net-mvc – 在kendo窗口中使用表单的PartialView
在我的项目中,我需要在Kendo窗口中放置一些表单.这些形式在另一部分视图中.我用它来加载局部视图:
@(Html.Kendo().Window() .Name("editPasswordPopUp") .Visible(false) .Modal(true) .Width(600) .Height(500) .Position(settings => settings.Top(70).Left(200)) .Title("Edit your password") .Content("loading user info...") .LoadContentFrom("EditPassword","Member") .Iframe(true) .Resizable() .Draggable() ) PartialView的动作: public ActionResult EditPassword() { return PartialView(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult EditPassword(EditPasswordViewModel viewModel) { [...] return RedirectToAction("Profile","Member",new {id = viewModel.Id}); [...] } 这是我的PartialView: @model Devoteam.CustomerPortal.ViewModels.EditPasswordViewModel @{ ViewBag.Title = "Edit"; Layout = null; } @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryval") @Scripts.Render("~/bundles/kendo") @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.Partial("_GenericMessage") <div id="messageError"> @Html.ValidationSummary() </div> // FIELDS <div class="buttons"> <input type="submit" value="Confirm" class="big-button" /> <input type="submit" value="Cancel" class="big-button" /> </div> } 当我单击按钮打开Kendo窗口时,部分视图正确加载到其中. 第二个问题:按取消按钮时如何关闭Kendo窗口? 先感谢您. (抱歉我的英语不好,这不是我的母语) 解决方法
在从PartialView的服务器端控制器代码提交之后,您可以在JavaScript中作为提交例程的一部分执行此操作,而不是自动关闭窗口/重定向.
>而不是在PartialView中返回RedirectToAction(“Profile”,“Member”,new {id:viewModel.Id},而只返回null. <input type="button" value="Edit Password" onclick="editPassword()" /> <script type="text/Javascript"> function editPassword() { var url = '@Url.Action("EditPassword","Password")?viewModel=' + '@Model'; var win = ('#editPasswordPopUp').data('kendoWindow').bind("close",function(e) { // Whatever you put here will run after your PartialView window.top.location.reload(); // reloads parent onclose of Kendo window }); win.refresh(url); win.open(); win.center(); } </script> >如果您希望窗口在提交后自动关闭并刷新父窗口,则需要使用自定义函数执行submit(),而不是使用您拥有的输入type =“submit”.这样,您可以像Dante建议的那样,将窗口关闭事件添加到PartialView中: <input type="button" value="Confirm" class="big-button" onclick="formSubmit() /> <script type="text/Javascript"> function formSubmit() { $('form').submit(); parent.$('#editPasswordPopUp').data('kendoWindow').close(); } </script> >对于关闭表单的取消按钮,您可以执行相同的操作.将它设为type =“button”而不是type =“submit”,放入onclick转到使用同一行关闭窗口的函数:parent.$(‘#editPasswordPopUp’).data(‘kendoWindow’) .关();. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 发送文件时的ASP.NET文件名编码
- asp.net – 从单独的配置文件中读取设置
- ASP.NET Core在Azure Kubernetes Service中的部署和管理
- ASP.NET MVC2与实体框架4 – AsEnumerable()或ToList()在存
- asp.net-mvc – React.js与asp.net MVC混合进行验证
- asp.net – IE超时后重新发送请求?
- ASP.NET捆绑和缩小 – CSS3属性失败
- asp.net-mvc – JQuery中的ViewBag
- "<a href='../目录" +变量+ 
- asp.net – 调试时编辑源代码
- asp.net-web-api – Autofac,Owin,Webapi并注入A
- asp.net-mvc – 添加一个默认的SelectListItem
- asp.net-mvc-3 – MVC3视图继承不可能?
- asp.net-mvc-3 – 如何添加html到页面里面的一个
- asp.net-mvc – asp.net mvc ajax post – redir
- ASP.NET MVC API 接口验证的示例代码
- ASP.NET web.config文件中的环境变量
- 内容管理 – ASP.NET建议[已结束]
- asp.net – 从网站下载后文件上的数字签名
- asp.net – BC30560:’ExtensionAttribute’在名