数据注释属性不会呈现的问题是什么?asp.net mvc 2项目不提供数据注释属性
的web.config
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
C#
public class SearchCriteria
{
[Required]
public string ControlNo { get; set; }
[Required]
public string Insured { get; set; }
[Required]
public string PolicyNumber { get; set; }
}
ASCX
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Core.SearchCriteria>" %>
<%@ Import Namespace="Core" %>
<% using (Html.BeginForm()) {%>
<%= Html.ValidationSummary(true) %>
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%= Html.LabelFor(model => model.ControlNo) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.ControlNo) %>
<%= Html.ValidationMessageFor(model => model.ControlNo) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.Insured) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Insured) %>
<%= Html.ValidationMessageFor(model => model.Insured) %>
</div>
不是mvc 3的“不显眼javascript”功能的一部分吗? –
究竟是什么问题? – samack
问题是,html 没有数据注释属性 – Cherven