[英]Html.TextBoxFor bootstrap Date mvc4
I've got this VMs' property:我有这个虚拟机的属性:
[Required]
[Display(Name = "Expiration date")]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
[DataType(DataType.Date)]
public DateTime ExpirationDate { get; set; }
and this code in model:和模型中的这段代码:
@Html.TextBoxFor(m => m.ExpirationDate, String.Format("0:dd/MM/yyyy}", Model.ExpirationDate),new{@class="form-control", type = "date"})
but only receive this:但只收到这个:
I mean there is no date from view model.我的意思是视图模型没有日期。 But value attribute is fill with date: http://clip2net.com/clip/m0/1380730052-clip-2kb.png
但 value 属性用日期填充: http : //clip2net.com/clip/m0/1380730052-clip-2kb.png
Actually the question: why does the date is not shown in input?实际上的问题是:为什么输入中没有显示日期?
你只需要这样做:
@Html.TextBoxFor(m => m.ExpirationDate, new{ @class="form-control", type = "date"})
Are you trying to have it as a placeholder?你想把它作为占位符吗? If so, I believe this should work (untested, though) -
如果是这样,我相信这应该有效(但未经测试)-
@Html.TextBoxFor(m => m.ExpirationDate, String.Format("0:dd/MM/yyyy}", Model.ExpirationDate),new{@class="form-control", type = "date", placeholder = m.ExpirationDate})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.