C#日历事件帮助 [英] C# Calendar Event Help

查看:108
本文介绍了C#日历事件帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在asp.net(C#)中建立一个网站,但在从日历中获取日期并为该日期分配一个值并将其打印到文本框中时遇到问题.我已经尝试过各种方法,但是它不会成功.我是一个严格的菜鸟,非常感谢您的帮助.
我最近的尝试看起来像这样:

如果Calendar1.SelectedDate ="
textBox1.Text =";

我尝试了日期时间,字符串等,但没有任何运气.

Hi I''m making a website in asp.net (C#)and I''m having problems getting the date from the calendar and assigning a value to that date and printing it out in a textbox. I''ve tried all sorts of things but it just won''t go. I''m a severe noob and would really appreciate some help.
My latest attempt looked somewhat like this:

if Calendar1.SelectedDate = ""
textBox1.Text = "";

I tried around with datetime, strings, etc. without any luck.
Help?

推荐答案

看看日历示例此处使用显示 [ ^ ] .
请记住,尽管这是一个服务器控件.
Have a look at the Calendar sample here[^].
Just using SelectedDate as show here[^].
Remember though that this is a server control.


请尝试以下针对C#Windows Forms的快速解决方案:

Try this quick solution for C# Windows Forms:

DateTime selectedDate = Convert.ToDateTime(monthCalendar1.SelectionStart);
textBox1.Text = selectedDate.ToShortDateString();



通过将代码放入monthCalendar1_DateSelected事件中进行测试.


尝试针对ASP.NET Web应用程序使用以下解决方案:




Test it by putting the code within the monthCalendar1_DateSelected event.


Try this solution for ASP.NET Web Applications:


DateTime selectedDate = Convert.ToDateTime(Calendar1.SelectedDate);
TextBox1.Text = selectedDate.ToShortDateString();



通过将代码放入Calendar1_SelectionChanged事件中进行测试.



Test by putting the code within the Calendar1_SelectionChanged event.


不完全是我想要的.我要做的是在文本框中显示事件.例如,如果用户的当前选择是2011年7月28日,它将写见面的朋友".不管怎么说,还是要谢谢你.它给了我一个大概的想法.
Not exactly what i wanted. What I''m to do is have events show in the textbox. For instance if the user''s current selection is 28/07/2011 It''ll write "meeting friends". Thanks anyway. It gave me a rough idea.


这篇关于C#日历事件帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆