你好,我正在尝试将简单的输入更改为我尝试过的文本的日期形式
显示具有DateTime属性的日期时间选择器
但是当我使用
@Html.TextBoxFor(model => model.dateFin, new { type = "date" })
但这不起作用
所以我使用简单的输入
@Html.EditorFor(model => model.dateDebut, new { htmlAttributes = new {@class = "form-control" } })
@Html.ValidationMessageFor(model => model.dateFin, "", new { @class = "text-danger" })
有人熟悉此表格吗?
答案 0 :(得分:0)
您可以为
之类的日期选择器创建自定义html帮助器控件。public static class HtmlHelper
{
public static IHtmlString DatePicker(this HtmlHelper helper, string id)
{
TagBuilder input = new TagBuilder("input");
input .Attributes.Add("type", "date");
input .Attributes.Add("id", id);
return new MvcHtmlString(input.ToString());
}
}
创建后,您需要在剃须刀页面中使用@using
来引用此类。而且您可以像@Html.DatePicker("dt1")