cshtml中的代码:
@Html.LabelFor(m => m.StartDateTime, new { @class = "lbl100" })
@Html.TextBoxFor(m => m.StartDateTime, "{0:yyyy-MM-dd}", new { @class = "form-control control120" })
@Html.LabelFor(m => m.EndDateTime, new { @class = "lbl100" })
@Html.TextBoxFor(m => m.EndDateTime, "{0:yyyy-MM-dd}", new { @class = "form-control control120" })
有两种方法可以从Ajax.Actionlink菜单中获取此操作 并形成pagedlist actionlink
为什么格式参数不起作用?
答案 0 :(得分:0)
如果String.Format
内的TextBoxFor
内的DisplayFormat
无法正常工作,请在DateTime
模型属性上使用[DisplayName("Start Date")]
[DataType(DataType.Date)] // if HTML5 is used you can apply this attribute
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
public DateTime StartDateTime { get; set; }
[DisplayName("End Date")]
[DataType(DataType.Date)] // if HTML5 is used you can apply this attribute
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
public DateTime EndDateTime { get; set; }
放置格式样式以强制执行日期输入。
php.ini