ASP.NET MVC, Linq to SQL Data Annotation Validation
I’m trying implement Data Annotation to my Linq to SQL objects. The .dbml file is generated and I’m not sure how to add data annotation to the objects without touching the generated source code.
I’m trying implement Data Annotation to my Linq to SQL objects. The .dbml file is generated and I’m not sure how to add data annotation to the objects without touching the generated source code.
I have a custom validation attribute which checks to see if two properties have the same values or not (like password and retype password):
I’m developing an ASP.NET MVC 5.2.3 custom data annotation for validation in Visual Studio 2015. It needs to take any number of fields and ensure that if one has a value, they all must have a value; if they’re all null/blank, it should be okay.
We have a need within some of our logic to iterate through the properties of a model to auto-bind properties and want to extend the functionality to include the new dataannotations in C# 4.0.
I have two separate VIEWS accessing the same MODEL. When I put the validator data annotations on the model, it works as advertised and prevents the data from being submitted (for both views) if left blank or not within range. However, I have one view that should be able to allow empty or null values to be saved for a property whereas another view needs to require information to be entered or selected before it lets it through. In other words, I’d like to turn off the validator on the property within the MODEL for one view and leave it on for the other view. Here’s the example code:
I try tovalidate two dates (start -> end) where only the first ist required, but when the user enters the second date it must be greater than the first. I’m using the MVC Foolproof package with the “PassOnNull” parameter.
I have a model containing a boolean with no [Required] attribute