2016-04-21 45 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中。