【发布时间】:2020-11-24 11:59:57
【问题描述】:
我是一名专业知识分子,如果遇到愚蠢的问题,请原谅我的问题,我在以下地址创建了一个小型 Web 应用程序 https://wireme.co.uk/BookList,但我无法正确显示日期,不确定我做错了什么,请在下面查看我的代码:
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace BookListRazor.Model
{
public class Book
{
[Key]
public int PO { get; set; }
[Required]
public string Creator { get; set; }
[Required]
public string Company { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy")]
public DateTime Date { get { return Mydate; } set { Mydate = value; } }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy")]
public DateTime Mydate = DateAndTime.Now;
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy")]
public DateTime MyDate { get; set; }
}
}
【问题讨论】:
-
也许这与日期格式中缺少右花括号
}有关
标签: c# asp.net datetime asp.net-mvc-4 aps