dotvvm验证问题

时间:2016-04-21 16:02:03

标签: dotvvm

查看使用验证器的文档

  

如果要验证某些属性,只需使用标准属性即可   来自System.ComponentModel.DataAnnotations命名空间。 DotVVM可以   将一些验证规则转换为javascript,因此验证可以   也可以在客户端执行。

然后我开发了以下代码:

using System;
using DotVVM.Framework.ViewModel;
using APP_MIS_FACTURAS.Models;
using System.Web;
using DotVVM.Framework.Controls.Bootstrap;
using System.ComponentModel.DataAnnotations;

namespace APP_MIS_FACTURAS.ViewModels
{
    public class InicioViewModel : DotvvmViewModelBase
    {

        [Required(ErrorMessage = "No se indica la contraseña del usuario")]
        public string usuario { get; set; }
        public string password { get; set; }

    }
}

但是我收到以下错误:

  

严重级代码描述项目文件行抑制状态   错误CS0246类型或命名空间名称'必需'无法找到   (你错过了使用指令或程序集吗?   参考?)APP_MIS_FACTURAS C:\ Users \ leojfn \ Documents \ Visual Studio   2015 \ Projects \ Cystem \ APP_MIS_FACTURAS \ APP_MIS_FACTURAS \ ViewModels \ InicioViewModel.cs 45 Active

我不知道是否需要导入某些特定库或者我需要安装NuGetPackage

1 个答案:

答案 0 :(得分:3)

在Solution Explorer窗口中右键单击该项目,选择Add Reference并选择System.ComponentModel.DataAnnotations。 默认情况下不会引用它,但它包含在.NET Framework中。

相关问题