0

I generate my views genericly with reflection so I am wondering if it is possible to get the validation attributes for all the properties of a class and then make them show in the view if there is a violation

For example:

public class Person 
{
    [Range(0,300)]
    [Required(ErrorMessage ="Please provide a weight")]
    public double Weight { get; set; }
}
3
  • Does this answer your query - stackoverflow.com/questions/7027613/… Aug 17, 2020 at 12:46
  • Thank you for your reply! Sadly, this answers only part of my query, I'm also wondering how I could display the error near the specific input field value, do you have any links on that? :-)
    – Glanie
    Aug 17, 2020 at 13:05
  • Take a look at this - stackoverflow.com/a/18965540 If this is not working out, will take a look at implementing something custom. Aug 17, 2020 at 15:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.