In Asp.Net, what control is more suitable for getting time (hh:mm) from user and pass it as a parameter to开发者_如何学Go a query?
If you don't mind using the ASP.NET Ajax Control Toolkit, you can use the MaskedEdit control. The second example shows you how to let users enter a time-value.
I believe you have to choose between the following three:
- Use a
TextBox
and do extensive input validation. - Use solution #1, but add a client side time picker on top of the
TextBox
. - Use two
DropDownList
controls - one for hours, one for minutes. - Use some kind of third-party time picker control.
Which one is better? I would say, that depends a lot on the expected users of your application. Anyone used to working with a keyboard is likely to prefer the TextBox
. Others might prefer the other options. For the broad masses, I would most likely go for solution #2, as it should suit both keyboard and mouse centric users.
If you choose to go with a third-party control, be wary that it might not degrade gracefully for users that do not accept Javascript. The control might just revert to a simple TextBox
, possibly without any validation logic.
精彩评论