I am using Google Chrome V28 as my browser - and have a problem with the DataAnnotations on my model, which force Chrome to use it's own inbuild calendar when rendering a datatime type in my view.
My model is:
public class ObScore
{
public int ObScoreId { get; set; }
...
...
[DisplayFormat(DataFormatString = "{0:dd MMMM yyyy}", ApplyFormatInEditMode = true)]
[Display(Name = "Date")]
[DataType(DataType.Date)]
public DateTime Date { get; set; }
...
...
}
There is definitely data in the model:
...but when displaying in Edit mode, Chrome shows:
Is this a known bug in Chrome, and is there anything I can do in my code, to force the date into the form?
Thanks, Mark
Model View Controller (MVC) MVC is a design pattern used to decouple user-interface (view), data (model), and application logic (controller). This pattern helps to achieve separation of concerns.
They are the same thing. C# is the language you have used to do your development, but ASP.NET MVC is the framework you used to do it.
ASP.NET MVC is no longer in active development.
ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites. It allows you to use a full featured programming language such as C# or VB.NET to build web applications easily.
Sorry to resurrect a 6 month old question, but I was having the same problem and have an answer that I feel is exactly what the OP was looking for.
While answer from mikhairu does work, it requires changing the type to text. The screenshots by the OP show Chrome's inbuilt datepicker UI, which requires the input to be type=date. Chrome requires the value of an input type=date to be in the format of YYYY-MM-DD, presumably to avoid any culture-specific ambiguity.
Therefore, in your model, add this data annotation to your date properties:
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With