Validation in MVC
public partial class Person
{
public string Name { get; set; }
public string MiddleName { get; set; }
public string SurName { get; set; }
public List<Person> getdata()
{
List<Person> lst = new List<Person>();
for (int i = 0; i < 5; i++)
{
Person OBJ = new Person();
OBJ.Name = i+"";
OBJ.SurName = "Sur" + i;
OBJ.MiddleName = "Mid" + i;
lst.Add(OBJ);
}
return lst;
}
}
Partial class Validation :-
public class Person_Validate
{
[Required]
public string Name { get; set; }
[Required]
public string MiddleName { get; set; }
[Required]
public string SurName { get; set; }
}
[MetadataType(typeof(Person_Validate))]
public partial class Person
{
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home