How to set a range to a Calender? Solved [modified]
-
Hello all , i've a calender that i want the user to navigate through a particular period of time ,for instance he has to apply for a vacation 3 days in advance ,and can only apply for a vacation in this year , so the calender range should be from NOW +3 days to NOW + an year this is the code and the calender doesnt comply to it why? how to fix it? Protected Sub ddlVacationTypes_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlVacationTypes.SelectedIndexChanged Dim startDate As DateTime = Convert.ToDateTime(Now.ToShortDateString) Select Case ddlVacationTypes.SelectedIndex Case 0, 2, 3 startDate = startDate.AddMonths(1) Case 1 startDate = startDate.AddDays(3) End Select Dim endDate As DateTime = startDate.AddYears(1) Dim dateSpan As TimeSpan = endDate.Date - startDate.Date Calendar1.SelectedDates.Clear() Dim i As Integer = 0 For i = 1 To dateSpan.Days Calendar1.SelectedDates.Add(startDate.AddDays(i)) Next End Sub
modified on Monday, November 9, 2009 2:23 AM
-
Hello all , i've a calender that i want the user to navigate through a particular period of time ,for instance he has to apply for a vacation 3 days in advance ,and can only apply for a vacation in this year , so the calender range should be from NOW +3 days to NOW + an year this is the code and the calender doesnt comply to it why? how to fix it? Protected Sub ddlVacationTypes_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlVacationTypes.SelectedIndexChanged Dim startDate As DateTime = Convert.ToDateTime(Now.ToShortDateString) Select Case ddlVacationTypes.SelectedIndex Case 0, 2, 3 startDate = startDate.AddMonths(1) Case 1 startDate = startDate.AddDays(3) End Select Dim endDate As DateTime = startDate.AddYears(1) Dim dateSpan As TimeSpan = endDate.Date - startDate.Date Calendar1.SelectedDates.Clear() Dim i As Integer = 0 For i = 1 To dateSpan.Days Calendar1.SelectedDates.Add(startDate.AddDays(i)) Next End Sub
modified on Monday, November 9, 2009 2:23 AM
How about this one? http://www.obout.com/calendar/tutorial_setmindate.aspx[^] In case of Calendar control, on each selection the whole page is posted back, which is definately not required. :-\
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
Hello all , i've a calender that i want the user to navigate through a particular period of time ,for instance he has to apply for a vacation 3 days in advance ,and can only apply for a vacation in this year , so the calender range should be from NOW +3 days to NOW + an year this is the code and the calender doesnt comply to it why? how to fix it? Protected Sub ddlVacationTypes_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlVacationTypes.SelectedIndexChanged Dim startDate As DateTime = Convert.ToDateTime(Now.ToShortDateString) Select Case ddlVacationTypes.SelectedIndex Case 0, 2, 3 startDate = startDate.AddMonths(1) Case 1 startDate = startDate.AddDays(3) End Select Dim endDate As DateTime = startDate.AddYears(1) Dim dateSpan As TimeSpan = endDate.Date - startDate.Date Calendar1.SelectedDates.Clear() Dim i As Integer = 0 For i = 1 To dateSpan.Days Calendar1.SelectedDates.Add(startDate.AddDays(i)) Next End Sub
modified on Monday, November 9, 2009 2:23 AM
This is in a website ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
How about this one? http://www.obout.com/calendar/tutorial_setmindate.aspx[^] In case of Calendar control, on each selection the whole page is posted back, which is definately not required. :-\
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
This is in a website ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
:thumbsup: Obout tools are awesome ,it opened a whole new world for me i really don know how to thank you ,Thank you veeeeeeeeeeeery muuuuuuuuuuuuuuuch :thumbsup:
Most welcome friend. Cheers. :rose:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript