如何在MVC textboxfor中将日期格式转换为yyyy-MM-dd [英] How to change date formate to yyyy-MM-dd in MVC textboxfor

查看:148
本文介绍了如何在MVC textboxfor中将日期格式转换为yyyy-MM-dd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从数据库获得的价值仅为yyyy-MM-dd格式,但它在文本框中抛出错误





错误 -



<input class =form-controlid =DDL_AnalystReportsParentObj_createDatename =DDL_AnalystReportsParentObj.createDatetype =datevalue =11/24 / 2016>





指定值11/24/2016不符合要求的格式, yyyy-MM-dd。



我的尝试:



我试图把

@Html.TextBoxFor(m => m.DDL_AnalystReportsParentObj.createDate,{0:yyyy-MM-dd},新{@type = date,@ class =form-control})

I am getting value from database as yyyy-MM-dd format only but it is throwing error in textboxfor


Error-

<"input class="form-control" id="DDL_AnalystReportsParentObj_createDate" name="DDL_AnalystReportsParentObj.createDate" type="date" value="11/24/2016">


The specified value "11/24/2016" does not conform to the required format, "yyyy-MM-dd".

What I have tried:

I tried to put
@Html.TextBoxFor(m => m.DDL_AnalystReportsParentObj.createDate, "{0:yyyy-MM-dd}" ,new { @type = "date", @class = "form-control" })

推荐答案

检查这个

c#使用输入类型=日期的Html.TextBoxFor? [ ^ ]


这篇关于如何在MVC textboxfor中将日期格式转换为yyyy-MM-dd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆