Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 为什么我的textBoxFor type=";日期“;不';显示日期?_Asp.net Mvc_Asp.net Core_Razor - Fatal编程技术网

Asp.net mvc 为什么我的textBoxFor type=";日期“;不';显示日期?

Asp.net mvc 为什么我的textBoxFor type=";日期“;不';显示日期?,asp.net-mvc,asp.net-core,razor,Asp.net Mvc,Asp.net Core,Razor,我有一个简单的局部视图,其中有一个TextBoxFor type=“date”(日期选择器)。 当我打开这个局部视图时,我希望文本框for type=“date”显示模型中的日期。 但是我够不着,TextBoxFor什么也不显示 Model.Dt_参考在ViewBag.Title中显示良好 以下是局部视图: @using w_TreatmentMVC.Models @model w_TreatmentMVC.Models.DemandeModel @{ Layout = null

我有一个简单的局部视图,其中有一个TextBoxFor type=“date”(日期选择器)。 当我打开这个局部视图时,我希望文本框for type=“date”显示模型中的日期。 但是我够不着,TextBoxFor什么也不显示

Model.Dt_参考在ViewBag.Title中显示良好

以下是局部视图:

    @using w_TreatmentMVC.Models
@model w_TreatmentMVC.Models.DemandeModel
@{
    Layout = null;
}
@{
    ViewBag.Title = "Modif demand n° " + Model.ID_DEMAND + " : " + Model.LI_TREATMENT + " : " + Model.DT_REFERENCE;
}
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>

<script type="text/javascript" src="../../Scripts/GlobalScripts.js"></script>

<div class="form-group">

    @Html.TextBoxFor(m => m.DT_REFERENCE, new { @type = "date", @Value = Model.DT_REFERENCE.ToString("dd/MM//yyyy") })

</div>

<div class="col-lg-12 col-md-12 col-xs-12" id="divPartial">
    <div class="col-lg-12 col-md-12 col-xs-12" id="divDemandOption">

        @Html.Action("SearchDemandOption", "Option")
    </div>
</div>
<input id="ButtonClose" type="button" value="Close" onclick="fctClose()" />

<script>

    function fctClose() {
        $("#divPopUpModal").fadeOut("slow");
        $('#divMainModal').fadeOut("slow");
    }
</script>
@使用w_TreatmentMVC.Models
@模型w_处理MVC.Models.demandemel
@{
布局=空;
}
@{
ViewBag.Title=“Modif demand n°”+Model.ID_demand+”:“+Model.LI_TREATMENT+”:“+Model.DT_REFERENCE;
}
@ViewBag.Title。
@查看包。留言
@Html.TextBoxFor(m=>m.DT_引用,新的{@type=“date”,@Value=Model.DT_引用.ToString(“dd/MM//yyyy”)})
@动作(“SearchDemandOption”,“Option”)
函数fctClose(){
$(“#divpopupmodel”).fadeOut(“慢”);
$('divmainmodel')。淡出(“慢”);
}
你能帮我吗

先谢谢你


Eric.

如果要将默认值设置为日期输入,则其值格式需要为 value=“yyyy-mm-dd”。如果您的DT_引用是datetime类型,请尝试这样做:

<input type="date" asp-for="DT_REFERENCE" value=@Model.DT_REFERENCE.ToString("yyyy-MM-dd").Split(" ")[0] />

结果:


非常感谢您,它非常适合我的需要。