Javascript Umbraco 7提交时模式弹出关闭
我在Umbraco MVC 7中有一个应用程序,我有一个按钮,可以调用模式弹出窗口来打开登录表单。这是放置在局部视图上的模式代码Javascript Umbraco 7提交时模式弹出关闭,javascript,jquery,asp.net-mvc,twitter-bootstrap,umbraco,Javascript,Jquery,Asp.net Mvc,Twitter Bootstrap,Umbraco,我在Umbraco MVC 7中有一个应用程序,我有一个按钮,可以调用模式弹出窗口来打开登录表单。这是放置在局部视图上的模式代码 @inherits UmbracoTemplatePage @using System.Web.Mvc.Html @using ClientDependency.Core.Mvc @using Umbraco.Web @using Umbraco.Web.Models @using Umbraco.Web.Controllers @{ var loginM
@inherits UmbracoTemplatePage
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@{
var loginModel = new LoginModel();
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco_client/ui/jquery.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
}
@Html.RenderJsHere()
<div class="modal fade bs-example-modal-sm" id="login" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Login</h4>
</div>
@using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin", null, new { @class = "form-horizontal", role = "form" }))
{
<div class="modal-body">
<div class="form-group">
<div class="col-sm-12 formError">
@Html.ValidationSummary()
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
@Html.TextBoxFor(m => loginModel.Username, new { @class = "form-control", placeholder = "Username" })
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
@Html.PasswordFor(m => loginModel.Password, new { @class = "form-control", placeholder = "Password" })
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Login</button>
</div>
}
</div>
</div>
</div>
@继承UmbracoTemplatePage
@使用System.Web.Mvc.Html
@使用ClientDependency.Core.Mvc
@使用Umbraco.Web
@使用Umbraco.Web.Models
@使用Umbraco.Web.Controllers
@{
var loginModel=new loginModel();
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
RequiresJs(“/umbraco_client/ui/jquery.js”);
RequiresJs(“/umbraco_client/Application/JQuery/JQuery.validate.min.js”);
RequiresJs(“/umbraco_client/Application/JQuery/JQuery.validate.unobtrusive.min.js”);
}
@Html.renderjsher()
&时代;
登录
@使用(Html.BeginUmbracoForm(“HandleLogin”,null,new{@class=“form horizontal”,role=“form”}))
{
@Html.ValidationSummary()
@TextBoxFor(m=>loginModel.Username,新的{@class=“form control”,placeholder=“Username”})
@Html.PasswordFor(m=>loginModel.Password,新的{@class=“form control”,placeholder=“Password”})
登录
}
因此,当我不键入任何内容并单击submit时,它会保持模式打开并显示验证错误,一切正常,但是如果我键入错误的凭据,它会关闭模式弹出窗口,相反,我希望保持打开并显示返回的错误。我知道它没有提交,因为如果我尝试刷新浏览器,它会要求我重新发送表单
有没有关于我需要做什么来修复它的建议
非常感谢当没有验证错误时,表单会被提交,因此会发生页面重新加载,这就是模式弹出窗口关闭的原因
解决方案:-您需要使用AJAX提交登录表单,以便只提交页面的该部分。当没有验证错误时,表单将被提交,因此会发生页面重新加载,这就是关闭模式弹出窗口的原因
解决方案:-您需要使用AJAX提交登录表单,以便只提交页面的该部分。当没有验证错误时,表单将被提交,因此会发生页面重新加载,这就是关闭模式弹出窗口的原因
解决方案:-您需要使用AJAX提交登录表单,以便只提交页面的该部分。当没有验证错误时,表单将被提交,因此会发生页面重新加载,这就是关闭模式弹出窗口的原因 解决方案:-您需要使用AJAX提交登录表单,以便只提交页面的该部分