Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Data Annotations for MVC in an ASP.NET WEBFORM Business Object Class?

How can I use this convention in an asp.net WEBFORM Business object class?

Example In MVC

using System.ComponenModel.DataAnnotation;

public class Customer
{
    [Required]
    [StringLength(5,20)]
    public string FirstName { get; set;}

    [Required]
    [StringLength(5,20)]
    public string LastName { get; set;}
}

I want to use this data annotation in my asp.net webform businessobject class for client validation and server validation.

like image 453
Zabahey Avatar asked Aug 07 '11 06:08

Zabahey


1 Answers

Unfortunately WebForms doesn't have native support of Data Annotations like MVC.

But you can use custom decisions:

  1. system componentmodel dataannotations for asp.net webforms

  2. Building an ASP.NET Validator Using Data Annotations

  3. ASP.NET: WebForms Validation with Data Annotations

like image 118
vladimir Avatar answered Sep 22 '22 08:09

vladimir