加载表单时,日期时间选择器控件为空 [英] Datetime picker control to be blank when the form loads

查看:125
本文介绍了加载表单时,日期时间选择器控件为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的表单中有一个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.

推荐答案

实际上,可以将DateTimePicker的Format设置为Custom并将自定义格式设置为空字符串(不是空,而是只是一个空格)

Actually it''s possible you can set Format of the DateTimePicker to Custom and set the custom format to a blank string (not empty but just one whitespace)

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




希望这会有所帮助.

http://stackoverflow.com/questions/846395/how-can-i-make-a-datetimepicker-display-an-empty-string [
Hi,

Hope this helps.

http://stackoverflow.com/questions/846395/how-can-i-make-a-datetimepicker-display-an-empty-string[^]


<script type="text/javascript">

function clearText(){
document.getElementById('txtSampleDate.ClientID').value = "";
}

window.onload=clearText();


<asp:textbox id="txtSampleDate" runat="server" xmlns:asp="#unknown" />


这篇关于加载表单时,日期时间选择器控件为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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