为什么会的HtmlHelper跳过验证属性 [英] Why HtmlHelper would skip validation attributes

查看:76
本文介绍了为什么会的HtmlHelper跳过验证属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 @ Html.TextBoxFor 和其他助手将跳过jquery.validation属性,并创建一个没有这些元素?我缺少一些借鉴什么?这是MVC 3.0项目。

Why @Html.TextBoxFor and other helpers would skip jquery.validation attributes and create elements without those? Am I missing some references or something? It's MVC 3.0 project.

如果我手动添加这样的:

If I add them manually like that:

@Html.TextBoxFor(x => x.Name, 
       new { data_val="true", data_val_required="Need that field" })

那么不显眼的审定工作。但它想建立的元素,并把基于模型的 DataAnnotations 的属性。模型是存在的,形式的身体里面的文本框,仍然无法正常工作。什么会是什么?

then unobtrusive validation works. But it's suppose build elements and put those attributes based on Model's DataAnnotations. Model is there, textbox inside of a form body, and still doesn't work. What could it be?

UPD: UnobtrusiveJavaScriptEnabled 设置为真正的web.config

推荐答案

请确保您的web.config文件中这两行

Please ensure these two lines in your web.config file

<appSettings>
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>

这篇关于为什么会的HtmlHelper跳过验证属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆