Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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
Entity framework 在Html.TextBoxFor上格式化日期-其他解决方案不起作用_Entity Framework_Asp.net Mvc 2 - Fatal编程技术网

Entity framework 在Html.TextBoxFor上格式化日期-其他解决方案不起作用

Entity framework 在Html.TextBoxFor上格式化日期-其他解决方案不起作用,entity-framework,asp.net-mvc-2,Entity Framework,Asp.net Mvc 2,使用EF生成的类,下面是我的元数据类: [DisplayName("Approved Date")] [DataType(DataType.DateTime)] [DisplayFormat(ApplyFormatInEditMode = true, HtmlEncode = false, NullDisplayText = "",

使用EF生成的类,下面是我的元数据类:

    [DisplayName("Approved Date")]
    [DataType(DataType.DateTime)]
    [DisplayFormat(ApplyFormatInEditMode = true,
                            HtmlEncode = false,
                            NullDisplayText = "", 
                            DataFormatString = "{0:MM/dd/yyyy}")]
    public object ApprovedDate{ get; set; }
观点:

<%: Html.EditorFor(model => model.Standard)%>
model.Standard)%%>
编辑:

<%:Html.EditorFor(model => model.ApprovedDate)%>
model.ApprovedDate)%>
DateTime.ascx:

<%string name = ViewData.TemplateInfo.HtmlFieldPrefix;%>
<%string id = name.Replace(".", "_");%>

<div class="clear">
    <div class="editor-label"><%:Html.LabelFor(model => model)%></div>
    <div class="editor-field">
        <%:Html.TextBoxFor(model => model)%>
        <%= Html.ValidationMessageFor(model => model)%>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {

        $("#<%=id%>").datepicker({
            showOn: 'both',
            dateFormat: 'm/d/yy',
            changeMonth: true,
            changeYear: true
        });
    });
</script>

型号)%%>
型号)%%>
型号)%%>
$(文档).ready(函数(){
$(“#”)日期选择器({
showOn:“两者都有”,
日期格式:“m/d/yy”,
变化月:对,
变化年:对
});
});
似乎什么都不管用。我必须维护绑定,所以我不想做原始HTML

所有日期字段都以相同的格式输出,其中包括时间

2009年3月12日12:00:00上午

它需要的是

3/12/2009

谢谢

我最后使用了
。似乎有效,并保留了绑定。

我最终使用了
。似乎有效,并保留绑定