1

在 MVC 的最新更新之前,我的页面的提琴手输出会生成这个 html。

   <div class="text-danger">
     <span class="field-validation-error" data-valmsg-for="Person.Initials" data-valmsg-replace="true">  
     &#39;Initials &#39; should not be empty.</span>
   </div>

更新包后的输出如下。

  <div class="text-danger">
    <span class="field-validation-valid" data-valmsg-for="Person.FirstName" data-valmsg-replace="true"></span>
  </div>

跨度不再包含错误消息?

需要明确的是,所有模型上的所有错误消息都在做同样的事情,这并不特定于某个特定领域。

配置文件没有改变,并且有以下几行:
如果我 ClientValidationEnabled 从配置文件中删除旧的(正确的?)HTML 生成。

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

我已经编辑了帖子以包含下面的模型。

[Serializable]
[DataContract(Name = "person", Namespace = "http://palantir.aureus.co.za/data/investor")]
    public partial class Person : Party
    {
        #region Constructor(s)
        /// <summary>
        /// Initialises a new instance of the <see cref="Person"/> class.
        /// </summary>
        [DebuggerNonUserCode]
        public Person()
        {
            this.PartyType = PartyType.Person;
            this.OnCreated();
        }

        /// <summary>
        /// Initialises a new instance of the <see cref="Person"/> class.
        /// </summary>
        /// <param name="tenant">The tenant.</param>
        public Person(Tenant tenant) : this() 
        {
            Contract.Requires<ArgumentNullException>(tenant != null);
            this.TenantId = tenant.Id;
            this.Tenant = tenant;
        }
        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the <c>FirstName for the Person</c>.
        /// </summary>      
        [DataMember(Name = "firstName", IsRequired = true)]
        [Required]
        [StringLength(250)]
        [DataType(DataType.Text)]
        [DisplayName("Given Name")]
        public string FirstName { get; set; }

        /// <summary>
        /// Gets or sets the <c>Surname for the Person</c>.
        /// </summary>      
        [DataMember(Name = "surname", IsRequired = true)]
        [Required]
        [StringLength(250)]
        [DataType(DataType.Text)]
        [DisplayName("Family Name")]
        public string Surname { get; set; }

        /// <summary>
        /// Gets or sets the <c>Initials for the Person</c>.
        /// </summary>      
        [DataMember(Name = "initials", IsRequired = true)]
        [Required]
        [StringLength(250)]
        [DataType(DataType.Text)]
        [DisplayName("Initials ")]
        public string Initials { get; set; }

}

我已将所有软件包更新到最新版本,MVC 在 5.2.2.0

4

0 回答 0