ASP.NET日期和时间选择器? [英] ASP.NET date and time picker?
问题描述
我使用ASP.NET 2.0中使用SQL Server 2005中我希望我的用户选择一个日期和时间,然后将这些值保存到数据库中。在VS我可以使用日历控件来获取日期,但什么是一个很好的为HANDELING用户选择日期,再加上它可能是什么都该用户还必须从控制选择时间。
I am using ASP.NET 2.0 with SQL Server 2005. I want my user to select a date and time and then save those values into the database. In VS I can use the Calendar control to get the date, but what is a good one for handeling the date the user select plus the time what ever it might be that the user must also select from a control.
在此先感谢!
推荐答案
下面是一个不错的自由控制:的 http://www.asp.net/community/control-gallery/item.aspx?i=535
Here's a nice free control: http://www.asp.net/community/control-gallery/item.aspx?i=535
和另一个(让你有一个选择)
And another (so you have a choice)
http://www.asp.net/community/控制画廊/ item.aspx?I = 3221
虽然是完全诚实的,我通常只使用下拉列表,并在code-背后将它们结合起来。 (虽然这可能被包裹在用户控制相当容易。)
Although to be perfectly honest, I normally just use drop-down lists and combine them in code-behind. (Although this could be wrapped in a user control fairly easily.)
ASPX:
<asp:TextBox ID="txtTime" runat="server" Width="90px"></asp:TextBox>
<asp:DropDownList ID="ddlAmPm" runat="server">
<asp:ListItem Selected="True">AM</asp:ListItem>
<asp:ListItem Selected="False">PM</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTime" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="TimeValidator" runat="server" ControlToValidate="txtTime" Display="Dynamic" ErrorMessage="Invalid Time. Enter time in a valid format. Example: 12:30 or 5:00" ValidationExpression="^(1[0-2]|[1-9]):[0-5][0-9]$" EnableClientScript="False"></asp:RegularExpressionValidator>
VB code-背后:
VB Code-behind:
Dim strDateTime As String = txtDate.Text & " " & txtTime.Text & " " & ddlAmPm.SelectedItem.Value
这篇关于ASP.NET日期和时间选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!