【问题标题】:ErrorMessage for decimal in entity-framework-core实体框架核心中十进制的错误消息
【发布时间】:2019-05-21 09:38:58
【问题描述】:

您好,我正在尝试自定义小数的错误消息,但看起来它不起作用

   using System;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using Market.Models;

    namespace Market.ViewModels
    {
        public class QuettaCatViewModel
    [Required(ErrorMessage = "Please fill Amount ")] //Work fine
            public int Qentity { get; set; }
     [Required(ErrorMessage = "What ever MSg go here")]//Not Fine Getting the default Msg 
            //[RegularExpression(@"^\d+.\d{0,2}$", ErrorMessage = "What ever MSg go here")]
            public decimal Bedget { get; set; }

【问题讨论】:

  • 我测试了代码,但运行良好。您是否在新项目中尝试过?您收到的默认消息是什么?
  • @XueliChen 傻我 -:) 忘了 _ValidationScriptsPartial ,谢谢

标签: asp.net-core-mvc entity-framework-core data-annotations entity-framework-core-2.2


【解决方案1】:

我的床需要@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-21
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    • 1970-01-01
    • 2021-07-14
    相关资源
    最近更新 更多