ascx 文件(用户控件)中的 asp.net mvc 客户端验证
我在 ascx 文件中有一个登录形式,我将其呈现为部分形式。 我如何向此表单添加客户端验证,有什么想法吗?
我的下面的代码不起作用
<%= Html.ValidationSummary(true, "Giriş başarısız oldu. Lütfen hataları düzeltip tekrar deneyin.") %>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("LogOnProcess", "Account")) { %>
<div>
<fieldset>
<legend>Hesap Bilgileri</legend>
<div class="editor-label">
<%= Html.LabelFor(m => m.UserName) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(m => m.UserName) %>
<%= Html.ValidationMessageFor(m => m.UserName) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(m => m.Password) %>
</div>
<div class="editor-field">
<%= Html.PasswordFor(m => m.Password) %>
<%= Html.ValidationMessageFor(m => m.Password) %>
</div>
<div class="editor-label">
<%= Html.CheckBoxFor(m => m.RememberMe) %>
<%= Html.LabelFor(m => m.RememberMe) %>
</div>
<p>
<input type="submit" value="Giriş" />
</p>
</fieldset>
</div>
<% } %>
I have a logOn forn in ascx files and I render it as partial.
How I can add a clinet side validation to this form, have any idea ?
My below code does not work
<%= Html.ValidationSummary(true, "Giriş başarısız oldu. Lütfen hataları düzeltip tekrar deneyin.") %>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("LogOnProcess", "Account")) { %>
<div>
<fieldset>
<legend>Hesap Bilgileri</legend>
<div class="editor-label">
<%= Html.LabelFor(m => m.UserName) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(m => m.UserName) %>
<%= Html.ValidationMessageFor(m => m.UserName) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(m => m.Password) %>
</div>
<div class="editor-field">
<%= Html.PasswordFor(m => m.Password) %>
<%= Html.ValidationMessageFor(m => m.Password) %>
</div>
<div class="editor-label">
<%= Html.CheckBoxFor(m => m.RememberMe) %>
<%= Html.LabelFor(m => m.RememberMe) %>
</div>
<p>
<input type="submit" value="Giriş" />
</p>
</fieldset>
</div>
<% } %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在某些 ascx 页面中遇到了内置客户端验证问题。我必须做的是使用 jQuery 验证来实现这一点。查看此链接:
http://docs.jquery.com/Plugins/Validation
I had issues with the built in client side validation in some ascx pages. What I had to do was use the jQuery validation to achieve this. Check out this link:
http://docs.jquery.com/Plugins/Validation