0

我正在創建我的第一個ASP.NET MVC2應用程序。我正在嘗試爲nerdDinner應用程序中演示的數據驗證創建一個部分類,但是MetaDataType具有以下消息的紅線:「無法找到類型或名稱空間'MetadataType'(您是否缺少using指令或程序集參考?)「在asp.net中進行數據驗證的部分類MVC2

有沒有我正在使用的」使用「命名空間?這裏是我的代碼:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Data.Linq; 
using System.Web.Mvc; 
using LanTracerMVC.Models; 

namespace LanTracerMVC.Models 
{ 
    [MetadataType(typeof(Request_Validation))] 
    //[Bind(Include = "ReqTypeID, ReqBy, ReqStatusID, NewLocationID")] 
    public partial class Request 
    { 


    }//end partial class 
    public class Request_Validation 
    { 


    } 
} 
+0

謝謝你,我添加使用System.ComponentModel.DataAnnotations;現在它的工作 – user695916 2011-04-07 02:20:39

回答

1

你缺少System.Data.ComponentModel.DataAnnotations

0

你有這些

命名空間: System.ComponentModel.DataAnnotations

大會: System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)

MSDN link