0

I'm using asp.net Calendar control and I want to enable people to only select dates that are two weeks from the current date.

E.g. today's date is 06/01/2015. Can only select dates 20/01/2015 onwards. So if they select a date like 19/01/2015, it'll say error.

I've tried

 if ( Calendar1.SelectedDate < DateTime.Now.AddDays(14)){

      Label8.Text = "*You can only select a date two weeks from now.";
      Label8.Visible = true;
   }

But there's an error. I've also tried the solution in

asp.net calendar control. Date selectable after 2 days from the current

but the error is the same.

Error 1 'ASP.reservations_aspx' does not contain a definition for 'Calendar1_SelectionChanged' and no extension method 'Calendar1_SelectionChanged' accepting a first argument of type 'ASP.reservations_aspx' could be found (are you missing a using directive or an assembly reference?)

Any help would be appreciated!

-I'm using VS 2013, web form.

Community
  • 1
  • 1
user2037510
  • 27
  • 1
  • 1
  • 9

1 Answers1

0

This is an easy one bro:

 Calendar1.VisibleDate = new DateTime(2015, 1, 20);

this will work :

  Calendar1.VisibleDate = DateTime.Now.AddDays(20);

Hope it works(sure it will):)

MH Mazen
  • 91
  • 1
  • 12
  • But i don't want it to just be today's date + 2 weeks that can be selected. What if i want to select a date and the current date is 25 jan? I want to allow 25 jan + 2 weeks = 8 feb selection onwards! – user2037510 Jan 05 '15 at 18:15
  • oh ok this will help: – MH Mazen Jan 05 '15 at 18:19
  • No no. I mean like.. As the days goes by, the selection is always current date + 2 weeks. How do i do that? So if i select a date 3 weeks later, I can only select a date that's 3 weeks later + 2 weeks, and i cannot select a date thats before that. – user2037510 Jan 05 '15 at 18:35
  • i can't get the idea here mate more explaning will help:/ – MH Mazen Jan 05 '15 at 19:44
  • like how do you want the result calender i understood that if the date where 1/1/2015 then the user cant select but dates from 1 --> 20 of the same mounth – MH Mazen Jan 05 '15 at 19:46
  • hmm. basically i'm using a calendar for reservations, where people can do a reservation only if it's made at least two weeks in advance. does that help? – user2037510 Jan 05 '15 at 19:47
  • so what is the proplem? – MH Mazen Jan 05 '15 at 19:53
  • but there's an error at the bottom as i mentioned :/ – user2037510 Jan 05 '15 at 20:05