c# - MVC2 验证模型也没有属性的验证属性

标签 c# asp.net-mvc

我有一个模型:

public class OverdraftForm
{
    public string CustomerId { get; set; }
    public PaymentType PaymentType { get; set; }

    public OverdraftType Type { get; set; }

    public decimal PermanentAmount { get; set; }
    public int ExpirationPeriod { get; set; }

    public decimal OnetimeAmount { get; set; }
    public DateTime ExpirationDate { get; set; }
    public CreditType CreditType { get; set; }
    public string Comment { get; set; }
}

我的 Action 是

public ActionResult CreateOverdraft(OverdraftForm form)
{
    if (form.Type == OverdraftType.Permanent)
        return CreatePermanentOverdraft(form);
    return CreateOnetimeOverdraft(form);
}

重点是当我调试它时,即使在操作的第一行 ModelState.IsValid 是 false,它说 OnetimeAmount 应该有一个值。我正在使用 MVC2,我猜它的某些更改会导致此问题。

最佳答案

关于c# - MVC2 验证模型也没有属性的验证属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3494116/

相关文章:

c# SQL Compact 监控 FileSystemWatcher 或 SqlDependency

c# - 多维数组,向量访问的元素

c# - 打开/关闭 NHibernate session

c# - DataGridView 不显示数据库中带有空图像的所有值

c# - MonoTouch instancesRespondToSelector 实现在哪里?

asp.net-mvc - MVC UpdateModel 和子类与基类

asp.net-mvc - Azure Web App VSTS 预编译 View (不可更新)

asp.net-mvc - CORS + Windows 身份验证与 Edge 或 IE 配合不佳

c# - ASP.NET MVC 3 WebGrid 分页问题

c# - 使用 iTextSharp 创建 PDF 时放置页码