c# - Apply validation for few sections in the same view in mvc -
i developing mvc project using c#. have 1 model called employeeeducationdetails
. lets have @ have created
public class educationlist { public list<employeeeducationdetailtable> employeeeducationlist { get; set; } public educationlist() { employeeeducationlist = new list<employeeeducationdetailtable>(); } public virtual employeemaintable employee_maintable { get; set; } public icollection<employeequalificationtypetable> employee_qualficationtypetable { get; set; } } public class employeeeducationdetailtable { public int employeeid { get; set; } public int employeeeducationdetailid { get; set; } [required(errormessage = "select qualification")] public int? employeequalificationtypeid { get; set; } [required(errormessage = "enter institute name")] public string employeeinstitutename { get; set; } [required(errormessage = "enter year of pass")] public datetime? employeeyearofpass { get; set; } [required(errormessage = "enter percentage")] public string employeepercentage { get; set; } }
until not facing problem. our requirement needs satisfy these conditions
- i have design 4 division on same view sslc, puc, degree, post degree using same model.
- need validate 1 section among 4 divisions because education mandatory employee.
- if data entered division has validate.
please give me idea this. appreciated.
note:here passing list.count
create 4 division dynamically , have use same model i.e. educationlist
if design permits, may provide checkbox against each division , use 'requiredif' conditional validation approach.
please visit following links know more on this:
requiredif conditional validation attribute
flexible conditional validation asp.net mvc sample code
hope you.
Comments
Post a Comment