我正在使用MVC3并添加了具有所需属性的模型验证。然后我创建了具有jQuery对话框的页面(不是Ajax对话框)。在这种情况下,验证不起作用。但是,如果我把对话框中的HTML页面,它工作正常。模型验证在jQuery对话框中不起作用
有没有人知道如何解决问题?
这里是我的JavaScript:
$(document).ready(function() {
$("#registerDialog").dialog({ autoOpen: false, show: "blind", hide: "explode", modal: true, resizable: false, height: 570, width: 390 });
$(".headerButton").button();
$(".accountBtn").button();
$('ul').roundabout({ autoplay: 'false', autoplayDuration: 3000 });
$("#registerBtn").click(function() {
$("#registerDialog").dialog("open"); return false; });
$("#closeRegisterDialog").click(function() { $("#registerDialog").dialog("close");
});
$("#registerBtnSbmt").click(function() {
$("#registerForm").submit(); return false; });
})
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { id = "registerForm" }))
{
<div id="registerDialog" title="Регистрация">
@Html.LabelFor(x => x.FirstName)
<br/>
@Html.TextBoxFor(x => x.FirstName, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.FirstName)
<br/>
@Html.LabelFor(x => x.LastName)
<br/>
@Html.TextBoxFor(x => x.LastName, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.LastName)
<br/>
@Html.LabelFor(x => x.Email)
<br/>
@Html.TextBoxFor(x => x.Email, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.Email)
<br/>
@Html.LabelFor(x => x.Password)
<br/>
@Html.TextBoxFor(x => x.Password, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.Password)
<br/>
@Html.LabelFor(x => x.ConfirmPassword)
<br/>
@Html.TextBoxFor(x => x.ConfirmPassword, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.ConfirmPassword)
<br/>
@Html.CheckBoxFor(x => x.RememberYou) запомнить Вас?
<br/>
<br/>
@Html.ActionLink("Сохранить", "LogIn", "Account", null, new { @class = "accountBtn", style = "font-size: 0.8em;", id = "registerBtnSbmt" })
<a href="#" class="accountBtn" id="closeRegisterDialog" style = "font-size: 0.8em;">Закрыть</a>
</div>
}
你可以发布你的代码用于生成对话框 – 2012-02-08 19:02:30
$(文件)。就绪(函数(){ $( “#registerDialog”)对话框({ 的AutoOpen:假, 显示: “盲”, 隐藏: “爆炸”, 模态:真, 可调整大小:假, 高度:570, 宽度:390 }); – Radislav 2012-02-08 19:11:51
$(“。headerButton”)。button(); $(“。accountBtn”)。button(); $('ul')。环岛({autoplay:'false',autoplayDuration:3000}); (“#registerBtn”)。click(function(){(“#registerDialog”)。dialog(“open”); return false; }); (“#closeDialog”)。dialog(“close”); }); (“#registerBtnSbmt”)。click(function(){0}(“#registerForm”)。submit(); return false; }); }); – Radislav 2012-02-08 19:12:02