我将 ASP.NET 2.0 与 SQL Server 2005 结合使用。我希望用户选择日期和时间,然后将这些值保存到数据库中。在 VS 中,我可以使用日历控件来获取日期,但是处理用户选择的日期以及用户还必须从控件中选择的时间有什么好处。
提前致谢!!
这是一个很好的免费控件:http://www.asp.net/community/control-gallery/item.aspx?i=535 http://www.asp.net/community/control-gallery/item.aspx?i=535
还有另一个(所以你有选择)
http://www.asp.net/community/control-gallery/item.aspx?i=3221 http://www.asp.net/community/control-gallery/item.aspx?i=3221
虽然说实话,我通常只使用下拉列表并将它们组合在代码隐藏中。 (尽管这可以很容易地包装在用户控件中。)
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 代码隐藏:
Dim strDateTime As String = txtDate.Text & " " & txtTime.Text & " " & ddlAmPm.SelectedItem.Value
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)