Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
Al Moje 14-Feb-12 4:51am    
Please post your code so that we could analyze...

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)

C#
this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
this.dateTimePicker1.CustomFormat = " "; //a string with one whitespace


This shows a blank date time. But the value does not change to null. You have to handle this issue seperately in your code
 
Share this answer
 
JavaScript
<script type="text/javascript">

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

window.onload=clearText();

ASP.NET
<asp:textbox id="txtSampleDate" runat="server" xmlns:asp="#unknown" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900