65.9K
CodeProject is changing. Read more.
Home

DotNet TimePicker control

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.40/5 (6 votes)

May 4, 2007

CPOL

1 min read

viewsIcon

34138

downloadIcon

1114

Easy to use DotNet TimePicker user control

Introduction

TimePicker is quiet a simple control which displays 3 dropdownlist with 'Hours',' Minutes' and 'Am/Pm' for display and selection. The control gets rendered as shown below. The 'DotNet_TimePicker.zip' contains the document with images showing the usage.

Using TimePicker is just as easy. Drag the 'TimePicker.ascx' into the page where you want use it.

Using the code

Time Picker control has 4 public property Hour, Minute, AmPm and Time. This control when added to a page renders 3 drpdown of Hour, Minute and AmPm.

The 'Time' property can be used directly to get a combined time attributes to be pushed into the DataBase. TimePicker.Time returns the Time in 24Hour format. i.e 15:36:00 The TimePicker has 'set' property of 'Time' eg

//
//   TimePickerTo.Time = "20:48:00";

//

This will set the TimePicker dropdown to 04:48 PM

The TimePicker has inbuilt requiredfield Validators too.

To see the usage download the code and run it as 'website' set 'Default.aspx' as the startup page.

Conclusion

I have deliberately kept very little frills to the control to make is more flexible. The code is available in download. Go ahead and add more feature to it. Its yours for free :) !

Happy Coding!!

Adarsh Nair