在日历上设置最小和最大日期? [英] Setting minimum and maximum date on Calendar?
本文介绍了在日历上设置最小和最大日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Visual Studio 2010,它只是一个常规的日历控件在这一刻...
目前我看到的东西像:
Calendar1.DateMin = DateTime.Now
但Visual Basic似乎并不喜欢(也许这是一个C#的东西?)...无论如何,如果有办法做到这将是一个很大的帮助。 p>
解决方案
您需要处理日历的 DayRender
事件:
私人MinDate As Date = Date.MinValue
私人MaxDate As Date = Date.MaxValue
受保护的子日历1_DayRender(发件人作为对象,e作为DayRenderEventArgs )处理Calendar1.DayRender
如果e.Day.Date< MinDate OrElse e.Day.Date> MaxDate Then
e.Day.IsSelectable = False
End If
End Sub
然后你可以在 Page_Load
中设置它:
MinDate = Date.Today
MaxDate = MinDate.AddDays(7)
I've had a look around, once again and can't find how to set the minimum and maximum dates allowed to be selected on a calendar in ASP.net with VB.
I'm using Visual Studio 2010 and it's just a regular Calendar control at the moment...
At the moment I've seen things like:
Calendar1.DateMin = DateTime.Now
But Visual Basic doesn't seem to like that (maybe it's a C# thing?)... Anyway, if there's a way to do this it'll be a great help!
解决方案
You need to handle the Calendar's DayRender
event:
Private MinDate As Date = Date.MinValue
Private MaxDate As Date = Date.MaxValue
Protected Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs)Handles Calendar1.DayRender
If e.Day.Date < MinDate OrElse e.Day.Date > MaxDate Then
e.Day.IsSelectable = False
End If
End Sub
Then you can set it for example in Page_Load
:
MinDate = Date.Today
MaxDate = MinDate.AddDays(7)
这篇关于在日历上设置最小和最大日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文