ASP.NET DateTime Picker

ASP.NET DateTime Picker

The answer to your question is that Yes there are good free/open source time picker controls that go well with ASP.NET Calendar controls.

ASP.NET calendar controls just write an HTML table.

If you are using HTML5 and .NET Framework 4.5, you can instead use an ASP.NET TextBox control and set the TextMode property to Date, Month, Week, Time, or DateTimeLocal — or if you your browser doesnt support this, you can set this property to DateTime.
You can then read the Text property to get the date, or time, or month, or week as a string from the TextBox.

If you are using .NET Framework 4.0 or an older version, then you can use HTML5s <input type=[month, week, etc.]>; if your browser doesnt support this, use <input type=datetime>.

If you need the server-side code (written in either C# or Visual Basic) for the information that the user inputs in the date field, then you can try to run the element on the server by writing runat=server inside the input tag.
As with all things ASP, make sure to give this element an ID so you can access it on the server side.
Now you can read the Value property to get the input date, time, month, or week as a string.

If you cannot run this element on the server, then you will need a hidden field in addition to the <input type=[date/time/month/week/etc.].
In the submit function (written in JavaScript), set the value of the hidden field to the value of the input type=date, or time, or month, or week — then on the server-side code, read the Value property of that hidden field as string too.

Make sure that the hidden field element of the HTML can run on the server.

In the textbox add this:


It gives you nice looking Datepicker like this:


Other variations of this are:


It gives you this look:



ASP.NET DateTime Picker

JQuery has the best datepicker IMHO. While its not specific to .Net is still works great.


<input type=text value=9/23/2009 style=width: 100px; readonly=readonly name=Date id=Date class=hasDatepicker/>

In head element:

<script src=../../Scripts/jquery-1.3.2.min.js language=javascript type=text/javascript/>
<script src=../../Scripts/jquery-ui-1.7.1.custom.min.js type=text/javascript/>

Simple as that!

Leave a Reply

Your email address will not be published.