Custom Data Annotation Validator Part I : Server Code

Posted by: K. Scott Allen, on 22 Feb 2011 | View original | Bookmarked: 0 time(s)

Let's say you want to create a GreaterThan validation attribute and use it like so: public class Trip { [Required] public DateTime StartDate { get; set; } [Required] [GreaterThan("StartDate")] public DateTime EndDate { get; set; } } The implementation would look something like this: public class GreaterThanAttribute : ValidationAttribute { public GreaterThanAttribute(string otherProperty) :base("{0} must be greater than {1}") { OtherProperty...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: .NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 508 | Hits: 23

Similar Posts

  • Using WCF with SQL Azure and Telerik OpenAccess more
  • Designer Support for One-Way navigations in Entity Framework 4 more
  • How to display data from different tables using one data source more
  • How To: Silverlight grid hierarchy load on demand using MVVM and RIA services more
  • EF4: Lazy Loading on By Default but what about pre Beta 2 Models? more
  • Migrated from Community Server to DasBlog more
  • Free software for you! WebsiteSpark let the mountain go to Microsoft instead. more
  • Announcing the WebsiteSpark Program more
  • An alternative to Crystal more
  • How To Cache Rows In DevExpress ASP.NET GridView more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD