Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to set a range to a Calender? Solved [modified]

How to set a range to a Calender? Solved [modified]

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alaminfad
    wrote on last edited by
    #1

    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

    A C 2 Replies Last reply
    0
    • A alaminfad

      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

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • A alaminfad

        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

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • A Abhishek Sur

          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

          A Offline
          A Offline
          alaminfad
          wrote on last edited by
          #4

          :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:

          A 1 Reply Last reply
          0
          • C Christian Graus

            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.

            A Offline
            A Offline
            alaminfad
            wrote on last edited by
            #5

            Thank you for replying yes It is a website , Abhishek Sur has replied with a very good solution ,check it out thx again :)

            1 Reply Last reply
            0
            • A alaminfad

              :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:

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups