本文介绍了加载表单时,日期时间选择器控件为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表单中有一个datetimepicker控件.除了一件事,它工作正常-
其默认值自动设置为今天的日期.我希望控件在窗体加载时为空白.
您能为我指出正确的方法吗?
谢谢您的时间.
Hi,
I have a datetimepicker control in my form. It works fine except for one thing-
Its default value is automatically set to today''s date. I want the control to be blank when the form loads.
Can you please point me in the right direction about how to do this?
Thanks for your time.
推荐答案
this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
this.dateTimePicker1.CustomFormat = " "; //a string with one whitespace
这显示空白的日期时间.但是该值不会更改为null.您必须在代码中单独处理此问题
This shows a blank date time. But the value does not change to null. You have to handle this issue seperately in your code
<script type="text/javascript">
function clearText(){
document.getElementById('txtSampleDate.ClientID').value = "";
}
window.onload=clearText();
<asp:textbox id="txtSampleDate" runat="server" xmlns:asp="#unknown" />
这篇关于加载表单时,日期时间选择器控件为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!