2016-04-21 61 views
1

查看文档使用验证与dotvvm验证

If you want to validate some property, just use standard attributes from the System.ComponentModel.DataAnnotations namespace. DotVVM can translate some validation rules into javascript, so the validation can be executed also on the client side.

问题,那么我制定了以下代码:

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; } 

    } 
} 

,但我得到了以下错误:

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'Required' could not be found (are you missing a using directive or an assembly reference?) APP_MIS_FACTURAS C:\Users\leojfn\Documents\Visual Studio 2015\Projects\Cystem\APP_MIS_FACTURAS\APP_MIS_FACTURAS\ViewModels\InicioViewModel.cs 45 Active

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

回答

3

右键单击解决方案资源管理器窗口中的项目,选择添加引用并选择System.ComponentModel.DataAnnotations。 默认情况下它未被引用,但它包含在.NET Framework中。