Data Annotations are used by frameworks such as ASP.NET MVC to enable a model-based validation approach and enforce consistent validation throughout the application, both on client and server side. They were first introduced in ASP.NET MVC 2. In addition to ASP.NET MVC, they can also be used with other technologies such as Entity Framework, either through manual placement of attributes on properties, or automatic generation with T4 templates.
Questions tagged [data-annotations]
3030 questions
1
vote
2 answers
Displaying TimeSpan Model in View with format mask mm:ss
I have a TimeSpan Model that I am trying to display in a View (@Html.EditorFor) with a masked format of mm:ss (duration measured in minutes and seconds). I DO NOT want/need hours or AM/PM, but my View without exception displays the mask = "--:-- --"…

Sam
- 11
- 1
- 5
1
vote
1 answer
How to change targetframework WP81 app
I have a Windows Phone 8.1 app in VS2015.
I am trying to add a property to my model that is not saved to the database. However, when I try to use the [NotMapped] annotation, I get the error:
The type or namespace name 'NotMapped' could not be…

Jerry
- 6,357
- 8
- 35
- 50
1
vote
1 answer
Creating a custom data annotation to ensure at least one of three fields in the model is populated
I am currently building a booking form using MVC within Umbraco. The properties I care about are as follows:
public class BookingModel{
public bool Previous { get; set; }
public bool Next { get; set; }
public int Stage {…

jezzipin
- 4,110
- 14
- 50
- 94
1
vote
1 answer
MVC client validation causing false errors
I'm hoping someone has run into something similar. A text input with text is triggering the client-side [Required] error message.
I have the following included in the master: