Setting minimum and maximum date on Calendar?

前端 未结 1 690
独厮守ぢ
独厮守ぢ 2021-01-12 16:23

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 Visu

相关标签:
1条回答
  • 2021-01-12 16:48

    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)
    
    0 讨论(0)
提交回复
热议问题