从 ASP.NET 日历获取显示的日期和时间
你好,iv 有一个 ASP 网站来预订航班,当我从日历中选择一个日期并在文本框中显示该日期时,它会显示该日期,但只有 00:00:00
这是我的代码:
protected void Calendar_SelectionChanged(object sender, EventArgs e)
{
dayToFly = Convert.ToString(Calendar.SelectedDate.Date);
txtDate.Text = dayToFly;
}
protected void btnSelect_Click(object sender, EventArgs e)
{
dayToFly = Convert.ToString(Calendar.SelectedDate.Date);
destination = dropDestinations.SelectedValue;
amountofpeople = Convert.ToInt16(dropAmount.SelectedValue);
lblInfo.Text = "You would like to Fly on " + dayToFly + " to " +
destination + " with " + amountofpeople + " people";
}
Hi iv got an ASP site to book flights, when i select a date from the calender and display that date in a textbox it displays the date but then only 00:00:00
here is my code for that bit:
protected void Calendar_SelectionChanged(object sender, EventArgs e)
{
dayToFly = Convert.ToString(Calendar.SelectedDate.Date);
txtDate.Text = dayToFly;
}
protected void btnSelect_Click(object sender, EventArgs e)
{
dayToFly = Convert.ToString(Calendar.SelectedDate.Date);
destination = dropDestinations.SelectedValue;
amountofpeople = Convert.ToInt16(dropAmount.SelectedValue);
lblInfo.Text = "You would like to Fly on " + dayToFly + " to " +
destination + " with " + amountofpeople + " people";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是标准 ASP.NET 日历控件吗?如果是这样,它只会给你一个日期,没有关联的时间(这就是为什么你得到的时间是“00:00:00”)。
您可能需要使用第三方日期/时间选择器控件,该控件允许用户选择日期和时间。我在工作中使用 Telerik,但它的价格是 $$$。
http://demos.telerik.com/aspnet-ajax/calendar /examples/overview/defaultcs.aspx
我确信有免费的可用。
Are you using the standard ASP.NET Calendar control? If so it will only give you a date, with no time associated ( that's why you get '00:00:00' for the time ).
You'll probably need to use third party date/time picker control(s), that allows the user to select both date AND time. I use the Telerik one here at work, but it costs $$$.
http://demos.telerik.com/aspnet-ajax/calendar/examples/overview/defaultcs.aspx
I'm sure there are free ones available though.