0

I have created a custom attribute in my asp.net MVC application using the following link:

http://www.falconwebtech.com/post/2012/04/18/MVC3-Custom-Validation-Attributes-for-Client-Server-Side-Validation-with-Unobtrusive-Ajax.aspx

but I am getting following errors:

Error 52 The type or namespace name 'IClientValidatable' could not be found (are you missing a using directive or an assembly reference?)
Error 53 The type or namespace name 'ModelClientValidationRule' could not be found (are you missing a using directive or an assembly reference?) Error 54 The type or namespace name 'ModelMetadata' could not be found (are you missing a using directive or an assembly reference?) Error 55 The type or namespace name 'ControllerContext' could not be found (are you missing a using directive or an assembly reference?)

I am using asp.net MVC 4 beta.

I tried to add reference of asp.net.MVC to the project but it is not available in add reference dialogue.

Please suggest how to fix it

DotnetSparrow
  • 27,428
  • 62
  • 183
  • 316

1 Answers1

2

Make sure you have added using System.Web.Mvc; to the top of your file which is the namespace in which this class is defined.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Hi @Darin, It is not available in list. where to add this ? – DotnetSparrow May 01 '12 at 14:16
  • To the top of your file. Where you are putting your `using` references. Also make sure that the `System.Web.Mvc` assembly is referenced in your project (when you create a new project it is added automatically) especially if you are trying to put this code in a class library or some other project type in which you forgot to reference it. – Darin Dimitrov May 01 '12 at 14:16
  • Hi @Darin: I am using this code in class library and I try to add reference of System.Web.MVC but it is not located in the popup in any tab like recent projects, .net componets and not in other. – DotnetSparrow May 01 '12 at 14:22
  • Make sure that this class library is targetting the full .NET 4.0 framework and not the Client Profile. Then System.Web.Mvc will show in the Net tab. – Darin Dimitrov May 01 '12 at 14:24
  • 2
    For what it's worth now... I had to add a reference to System.Web.WebPages as well. – virtualadrian Oct 18 '14 at 21:06