我有一个文本框在mvc4应用程序如下。如何删除mvc4文本框中的默认日期?
@Html.TextBoxFor(x=>x.dateofAction, ViewBag.filterdateTime as string, new { @id = "dateofAction", @placeholder = "Date Of Action", @class = "txtBox form-control calender validate[required]" })
我对这个文本框使用jquery压光机。
$(document).on('focus', '.calender', function(){
$(this).datepicker({
dateFormat: "dd/mm/yy",
changeMonth: true,
changeYear: true,
showOn: 'button',
buttonImage: '/images/icondate.png',
buttonImageOnly: true
})
});
这是我的模型
[DisplayName("dateofAction")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
public DateTime dateofAction { get; set; }
我在第一次页面加载默认的日期1/1/0001 12:00:00 AM
在文本框中显示的是面临的问题。其实我想显示占位符的价值。
我可以知道为什么我无法获得占位符值吗?
让你属性可为空 - 'public DateTime? dateofAction {get;组; }'(和**不**设置'value'属性!) –
谢谢斯蒂芬。像'charm'这样的作品 –
并且删除'$(document).on('focus','.calender',function(){'并用'$('#dateofAction')替换它。datapicker({...} );'并移除'new {@id =“dateofAction”}(它已经有了'id') –