简体   繁体   English

在ASP.net中使用Type = datetime的TextBox

[英]Using TextBox with Type=datetime , in ASP.net

I have textbox like that (VS 2010): 我有这样的文本框(V​​S 2010):

<asp:TextBox type="date" ID="rSLA" runat="server" ></asp:TextBox>

and it's working fine, but when I change the type to : datetime (cause I need date and hour) , the datepicker not working. 并且工作正常,但是当我将类型更改为:datetime(因为我需要日期和小时)时,datepicker无法正常工作。 why? 为什么?

Thank you. 谢谢。

Which browser are you using? 您正在使用哪个浏览器? I notice on there that for Chrome, datetime is unsupported but datetime-local is, maybe that solves your problem. 我注意到在那里 ,对于浏览器, datetime是不支持的,但datetime-local的,也许这可以解决你的问题。

setting type="datetime" for textbox it Doesn't Mean that it will show calender for You. 为文本框设置type="datetime"并不意味着它将为您显示日历。 You can Use Calender from Ajax 您可以从Ajax使用日历

in front of TextBox 在TextBox前面

<asp:TextBox ID="rSLA" runat="server" ></asp:TextBox>
<asp:Calendar ID="Calendar1" runat="server" Width="150px" 
                DayNameFormat="Shortest"  Height="25px" /> 
            </asp:Calendar> 

Refer this http://www.codeproject.com/Articles/19991/DatePicker-in-ASP-NET-and-AJAX-Control-Toolkit 请参阅此http://www.codeproject.com/Articles/19991/DatePicker-in-ASP-NET-and-AJAX-Control-Toolkit

If you're trying to use HTML5 datetime input type, it's good to check on what browsers support it first. 如果您尝试使用HTML5日期时间输入类型,最好先检查一下哪些浏览器支持它。 According to this , it only appears a few mobile browsers are supported. 根据这个 ,只出现了几个手机浏览器的支持。 So instead you should use a 3rd party Datepicker. 因此,您应该使用第三方Datepicker。 There's a built-in one that doesn't work very well, there's one in the Ajax Control Toolkit that works well, jQuery UI has one (that's my personal pref) or you can Google for one. 有一个内置的不能很好地工作,有一个Ajax Control Toolkit很好地工作, jQuery UI有一个(这是我个人的偏好),或者您可以用Google买一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM