Anyone know of a free date and *time* ASP.NET custom control [closed]
-
08-07-2019 - |
Question
Every time I have to build a form with a DateTime
field I try to find a decent free custom control - I always fail.
I cannot figure out why it isn't built in the .NET but let's forget about for a minute and concentrate on my question :D
Anyone got one?
Solution
Use two separate TextBoxes, one for date and one for time. For the date one, use the ASP.NET Ajax Control Toolkit Calendar control, as someone else pointed out.
For the time TextBox, have a look at the MaskedEditExtender control in the same toolkit. You can set it to display ::__ AM/PM and let the user fill in. You can fill with zeros if they just type "3p" and tab out.
To use it, you need a TextBox. You set the MaskedEditExtender's TargetControlID to the TextBox's ID. Here are some attributes you'll need to set in the MaskedEditExtender tag for time entry:
Mask="99:99"
AutoCompleteValue="00:00"
AcceptAMPM="true"
MaskType="Time"
Also, if you get a weird FindControl-related error, make sure that your MaskedEditExtenders all have IDs set.
OTHER TIPS
Just combine these two
http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/
http://keith-wood.name/timeEntry.html
jQuery is where it's at!
Check the Calendar control extender from the MS AJAX Control Toolkit, I really like it.
I just did a quick Google and came across this one...
http://www.softcomplex.com/products/tigra_calendar/demo1.html
Looks like it supports dates and times, and it appears to be free.
I've had fairly good luck with this one:
The Ra-Ajax Calendar control will actually be released the upcoming Friday (28th of November 2008) with Time support (two textboxes between the Today button and the dates)
Ra-Ajax is LGPL licensed and Free of Charge to use...
This works nicely indeed.
<asp:TextBox runat="server" ID="startDate" autocomplete="off" />
<ajaxToolkit:CalendarExtender
ID="defaultCalendarExtender"
runat="server"
TargetControlID="startDate" />
<asp:TextBox ID="startTime" runat="server" Columns="8"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender
ID="startTime_MaskedEditExtender1" runat="server"
Enabled="True"
TargetControlID="startTime"
MaskType="Time"
AutoCompleteValue="09:00"
Mask="99:99"
AcceptAMPM="true">
</ajaxToolkit:MaskedEditExtender>
<ajaxToolkit:MaskedEditValidator
ID="MaskedEditValidator1"
runat="server"
ControlExtender="startTime_MaskedEditExtender1"
ControlToValidate="startTime"
IsValidEmpty="False"
EmptyValueMessage="Time is required"
InvalidValueMessage="Time is invalid"
Display="Dynamic"
TooltipMessage="Input a time"
EmptyValueBlurredText="*"
InvalidValueBlurredMessage="Check time">