Click here to Skip to main content
15,887,214 members
Articles / Programming Languages / C#
Article

DotNet TimePicker control

Rate me:
Please Sign up or sign in to vote.
1.40/5 (6 votes)
25 Jul 2007CPOL1 min read 33.7K   1.1K   10   4
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

License

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


Written By
Web Developer
India India
Compulsive coder

Comments and Discussions

 
GeneralMy Vote of 5 Pin
Priyanka Sundaraj26-Apr-14 3:03
Priyanka Sundaraj26-Apr-14 3:03 
GeneralRe: My Vote of 5 Pin
Adarsh N17-Jun-14 4:13
Adarsh N17-Jun-14 4:13 
GeneralError Pin
Veesam Suresh Kumar14-Jun-07 17:28
Veesam Suresh Kumar14-Jun-07 17:28 
GeneralRe: Error Pin
Adarsh N24-Jul-07 18:24
Adarsh N24-Jul-07 18:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.